Question

On R, I need to use two different methods to estimate the following function: where the...

On R, I need to use two different methods to estimate the following function:

f(x) = \alpha _1I(U\leq x)+\alpha _2I(U> x)

where the two alphas are unknown constants, U is a random number in between the minimum and maximum values of x, and I is an indicator function (which equals 1 when the statement is true and 0 when false). X is a variable from a dataset, part of which I have included below:

X Y
-0.66461 6.643187
0.397653 0.867769
-0.58379 4.874199
0.054239 -0.18325
-0.13224 0.736208
0.992707 6.305005
-0.02192 0.90596
0.98336 7.073595
0.152927 0.39065
0.961129 6.735509

How would I go about doing this in R? There are other parts to the question, which I can post if required.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The data input would be as below.

---------------------------------------------------

> library(readr)
> dat <- read_delim("dat", "\t", escape_double = FALSE, trim_ws = TRUE)

---------------------------------------------------

The two methods would only vary on the basis of different regression model. This is basically a type of dummy variable analysis. The two independent variables are basically dummy variables, such that IU <r) = 1 - IU >r) .

1. The regression model would be as Y = 1/( U X ) + 2/(U > X) . Note that the intercept coefficient is not included, so that the regression model avoids the dummy variable trap. The following script would work for this model. Also note that different U's would yield different output.

---------------------------------------------------

# Select the random U
U <- sample(dat$X,1)

# Create the dummy variables
I1 <- as.numeric(U <= dat$X)
I2 <- as.numeric(U > dat$X)

# The regression without intercept . . .
summary(lm(dat$Y ~ 0 + I1 + I2))

---------------------------------------------------

2. Putting IU <r) = 1 - IU >r) in the above regression, we have Y = 0 (1 - IU >r)) + 2/(U > X) or Y = 01-01IU > r) + QIU > X) or Y = 01 +(02 - 01/(U >r) or Y = a1 +31(U >r) . The script is as below.

---------------------------------------------------

# Select the random U
U <- sample(dat$X,1)

# Create the dummy variable
I1 <- as.numeric(U > dat$X)

# The regression without intercept . . .
summary(lm(dat$Y ~ I1))

---------------------------------------------------

Add a comment
Know the answer?
Add Answer to:
On R, I need to use two different methods to estimate the following function: where the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. A certain continuous distribution has cumulative distribution function (CDF) given by F(x) 0, r<0 where...

    1. A certain continuous distribution has cumulative distribution function (CDF) given by F(x) 0, r<0 where θ is an unknown parameter, θ > 0. Let X, be the sample mean and X(n)max(Xi, X2,,Xn). (i) Show that θ¡n-(1 + )Xn ls an unbiased estimator of θ. Find its mean square error and check whether θ¡r, is consistent for θ. (i) Show that nX(n) is a consistent estimator of o (ii) Assume n > 1 and find MSE's of 02n, and compare...

  • 2.10.4 Given a function f(x,y) on a compact region E in R^2, Find the maximum and...

    2.10.4 Given a function f(x,y) on a compact region E in R^2, Find the maximum and minimum values of f on E, and the points at which these extreme values are attained. f(x, y) = x2 sin y + x, and E is the filled rectangle where -1 < x < 1 and | 0 < a < .

  • explan the answer 10: A certain continuous distribution has cumulative distribution function (CDF) given by F(r)...

    explan the answer 10: A certain continuous distribution has cumulative distribution function (CDF) given by F(r) 0, <0 where θ is an unknown parameter, θ > 0. (i) Find (a) the p.d.f., (b) the mean and (e) the variance of this distribution. (ii) Suppose that X (Xi, X2, Xn) is a random sample from this distribu- tion and let Y max(Xi, XXn). Find the CDF and p.d.f. of Y. Hence find the value of a for which EloY)

  • I need help writing the helper function find() and removeAll(). I'm pretty sure i have find...

    I need help writing the helper function find() and removeAll(). I'm pretty sure i have find wrong. please help me! I included the top portion of my code so you get an idea of whats going going. on Java language someone asked structure of list node too? i dont know what they mean public class LinkedIntList public ListNode front; // first value in the list // post: constructs an empty list public LinkedIntList( front null; e public LinkedIntList(int[l arri this);...

  • I need a function in R or just code in R that will solve this. (Thanks...

    I need a function in R or just code in R that will solve this. (Thanks in advance) 1. The probability density function for Exponentiated Weibull distribution is and its corresponding cdf is given by F(x) 1-exp(x) This distribution is a popular distribution in analyzing lifetime data. a) b) Find the mean and variance when-10, α 2 and β-4 Compute the probability when the random variable X is between two standard deviation of the sample mean, where λ-10, α-2 and...

  • Given the periodic function 5 f(1) = { 1 f (+4) 0<i and I<2 2 <r...

    Given the periodic function 5 f(1) = { 1 f (+4) 0<i and I<2 2 <r and I<4 otherwise and its graph is displayed below. 6 5 4 y 3 2 1 0 -2 2 4 6 00+ x The function may be approximated by the Fourier series f(t) = 40 + 1 (an cos ( 172 ) + bn sin where L is the half-period of the function. + bn sin ne :)), L Calculate the coefficients of the...

  • i need help with all parts. i will rate. thank you very much. The maximum value...

    i need help with all parts. i will rate. thank you very much. The maximum value of the function f(x,y) = xy on the line 4x+9y=36 is 8 9 O 10 O 18 Suppose u = (-5,3) and v=(8,1) Find || +v|| O-37 O 5 07 17 Consider the rectangular planar lamina R = {(x,y): 0<x<3,05y<2} with density p(x,y) = x² + y² has a mass of 0 24 O 25 O 26 O 27

  • I need the answer for (ii) 1. A certain continuous distribution has cumulative distribution function (CDF)...

    I need the answer for (ii) 1. A certain continuous distribution has cumulative distribution function (CDF) given by F(a)-0, <0 where θ is an unknown parameter, θ > 0. Let X, be the sample miean and X(n) = max {Xu X2, ,..} 0) Show that n +, is an unbiased stimator of o Find its mean squnare error and check whether θι, is consistent for θ. (ii) Show that 2n- Xn) is a consistent estimator of fe (iii) Assume n...

  • Consider the following function. f(x) = 5 sinh (3r). a = 0, n=5,-0.3<r <0.3 (a) Approximate...

    Consider the following function. f(x) = 5 sinh (3r). a = 0, n=5,-0.3<r <0.3 (a) Approximate f by a Taylor polynomial with degree n at the number a. 3 45x 2 81 5 T5(x) = | 15x + + -X 8 (b) Use Taylor's Inequality to estimate the accuracy of the approximation f = 7,(x) when x lies in the given interval. (Round the answer to four decimal places.) |R5(x)] = 5.19674 X

  • In our experiment we will use three different substrates: 1°, n-butyl chloride; 2°, sec-butyl chloride; and...

    In our experiment we will use three different substrates: 1°, n-butyl chloride; 2°, sec-butyl chloride; and 3°, tert- butyl chloride, and we will evaluate their reactivity and the rate of the reaction in an SN1 reaction. We will use an acid-base indicator to monitor the completion of the reaction and a salt, silver nitrate, to obtain a precipitate. The success of the reaction is evidenced by the change in color of the indicator (from orange to red) due to the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT