Question

Use the lm command to create the linear-log model in R. The linear log function takes...

Use the lm command to create the linear-log model in R. The linear log function takes the form Y=a+blog(x)

Homework Answers

Answer #1
> #generating data for the problem
> n=500
> x <- 1:n
> set.seed(10)
> y <- 1*log(x)-6+rnorm(n)
> 
> #plotting the data
> plot(y~x)
> 
> #fitting log model
>
> fit <- lm(y~log(x))
> #Summary of the model
> summary(fit)

Call:
lm(formula = y ~ log(x))


Residuals:
     Min       1Q   Median       3Q      Max 
-3.06157 -0.69437 -0.00174  0.76330  2.63033 


Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  -6.4699     0.2471  -26.19   <2e-16 ***
log(x)        1.0879     0.0465   23.39   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.014 on 498 degrees of freedom
Multiple R-squared:  0.5236,    Adjusted R-squared:  0.5226 
F-statistic: 547.3 on 1 and 498 DF,  p-value: < 2.2e-16



>
> coef(fit)
(Intercept)      log(x) 
  -6.469869    1.087886 
> 
> #plotting 
> x=seq(from=1,to=n,length.out=1000)
> y=predict(fit,newdata=list(x=seq(from=1,to=n,length.out=1000)),
+           interval="confidence")
> matlines(x,y,lwd=2)

Output:

Know the answer?
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
Similar Questions
R-Studio Write a generic R function of white test. It takes a fit of linear model...
R-Studio Write a generic R function of white test. It takes a fit of linear model and outputs the value of white statistics, degree of freedom, and p-value for the hypothesis testing of constant-variance assumption. It should be similar to bptest as in lmtest package.
If we have a multiple linear regression model: lm(life ~ male + birth + divo +...
If we have a multiple linear regression model: lm(life ~ male + birth + divo + beds + educ + inco, data = DATA) (1) What R command should we use to plot it standardized residuals against the FITTED values? (2) What R command should we use to compute and plot the leverage of each point and identify the points that have a leverage larger than 0.5? (3) What R command should we use to compute the Cook's distance for...
Consider the sample regressions for the linear, the logarithmic, the exponential, and the log-log models. For...
Consider the sample regressions for the linear, the logarithmic, the exponential, and the log-log models. For each of the estimated models, predict y when x equals 70. (Do not round intermediate calculations. Round final answers to 2 decimal places.) Response Variable: y Response Variable: ln(y) Model 1 Model 2 Model 3 Model 4 Intercept 18.36 −6.68 1.47 1.01 x 1.67 NA 0.05 NA ln(x) NA 29.69 NA 0.94 se 23.72 19.55 0.13 0.11
Use R to tackle the problem Write a function which takes as input x = (x1,...
Use R to tackle the problem Write a function which takes as input x = (x1, . . . , xn) and y = (y1, . . . , yn) and outputs the slope and intercept given by the method of least squares.
**Please use MATLAB** 11)Function: Create a function that takes inputs “x” and “z” and generates any...
**Please use MATLAB** 11)Function: Create a function that takes inputs “x” and “z” and generates any random matrix of dimension “x” or “z”, whichever is larger. 12)Function: Create a function that takes a generic matrix, x, and finds the smallest value in the matrix. The function must work for matrices of any size or dimension. **Please use MATLAB** Also, please include code used for the function. I have tried several times but have been unsuccessful.
Use the IS-LM model to predict the effect of an increase in the money supply on...
Use the IS-LM model to predict the effect of an increase in the money supply on output, Y , and the real interest rate, r in the short-run. What is the effect of this policy on these variables in the long-run? How do you know?
Linear Regression Use linear regression to find the equation for the linear function that best fits...
Linear Regression Use linear regression to find the equation for the linear function that best fits this data. Round both numbers to two decimal places. Write your final answer in a form of an equation y=mx+by=mx+b x 1 2 3 4 5 6 y 98 122 156 176 213 219
Use linear regression to find the equation for the linear function that best fits this data....
Use linear regression to find the equation for the linear function that best fits this data. Round both numbers to two decimal places. Write your final answer in a form of an equation y = m x + b x 1 2 3 4 5 6 y 87 102 119 149 158 178
1. Show what happens to Y and r using the IS-LM model when a) There is...
1. Show what happens to Y and r using the IS-LM model when a) There is a decrease in money demand b) Congress reduces government spending c) There is an increase in consumption spending by househol
Use linear regression to find the equation for the linear function that best fits this data....
Use linear regression to find the equation for the linear function that best fits this data. Round both numbers to two decimal places. Write your final answer in a form of an equation y=mx+by=mx+b x 1 2 3 4 5 6 y 93 110 138 170 191 212   
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT