There is the 2-parameter linear model where e is the error vector of length n given by e ~ N(0, 22 In) where In is the n by n identity matrix.
I want to use glm(y ~ x, family = gaussian(), data = ...) in R. Please advise how to specify the given error vector.
# The required function is
n=30
## independent variable
x=rnorm(n, 4, 2)
## Error with mean zero and variance 22
e=rnorm(n, 0, sd=sqrt(22))
## Dependent variable with variance 22
y=x+e
data=cbind(y, x)
data=data.frame(data)
## Required model
model=glm(y~x, family = gaussian, data)
summary(model)
## For check the error variance
model=lm(y~x)
summary(model)
#########################
### Run the model
> n=30
> ## independent variable
> x=rnorm(n, 4, 2)
>
> ## Error with mean zero and variance 22
> e=rnorm(n, 0, sd=sqrt(22))
>
> ## Dependent variable with variance 22
> y=x+e
>
> data=cbind(y, x)
> data=data.frame(data)
>
> ## Required model
>
> model=glm(y~x, family = gaussian, data)
> summary(model)
Call:
glm(formula = y ~ x, family = gaussian, data = data)
Deviance Residuals:
Min 1Q Median 3Q Max
-9.0524 -1.4839 -0.0806 2.1880 11.1185
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.03522 1.89826 0.019 0.9853
x 1.06081 0.45707 2.321 0.0278 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 17.304)
Null deviance: 577.72 on 29 degrees of freedom
Residual deviance: 484.51 on 28 degrees of freedom
AIC: 174.59
Number of Fisher Scoring iterations: 2
>
> model=lm(y~x)
> summary(model)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-9.0524 -1.4839 -0.0806 2.1880 11.1185
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.03522 1.89826 0.019 0.9853
x 1.06081 0.45707 2.321 0.0278 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.16 on 28 degrees of freedom
Multiple R-squared: 0.1613, Adjusted R-squared: 0.1314
F-statistic: 5.387 on 1 and 28 DF, p-value: 0.0278
There is the 2-parameter linear model where e is the error vector of length n given...
3. Consider the multiple linear regression model iid where Xi, . . . ,Xp-1 ,i are observed covariate values for observation i, and Ei ~N(0,ơ2) (a) What is the interpretation of B1 in this model? (b) Write the matrix form of the model. Label the response vector, design matrix, coefficient vector, and error vector, and specify the dimensions and elements for each. (c) Write the likelihood, log-likelihood, and in matrix form. aB (d) Solve : 0 for β, the MLE...
1. Consider a GLM (generalised linear model) for a Poisson random sample Y1,. .. , Y, with \Vi each Yi having a pdf or pmf f(y; A;) = i= 1, . .. ,n. Yi = 0, 1,2, -..; ^; > 0; Y;! Note that the pdf from an exponential family has the following general form b(0) + c(y, a(o) y0 exp f(y; 0, 6) = Suppose the linear predictor of the GLM is n = a+Bxi, with (a,B) being the...
3. Consider the multiple linear regression model where Xii, . .. , Xp-i.i are observed covariate values for observation i, and εί udN(0, σ2) (a) What is the interpretation of in this model? (b) Write the matrix form of the model. Label the response vector, design matrix, coefficient vecto and error vector, and specify the dimensions and elements for each. (c) Write the likelihood, log-likelihood, and 쓿 in matrix form. (d) Solve = 0 for β, the MLE of the...
The standard linear regression model is: y = Xw+e, where X is an nxd matrix of predictor vari- ables, y is an n-dimensional vector of response variables, and e N (0,021) is an n-dimensional vector of model errors. (a) What is the PDF of y in terms of X,w, o?? N(0,p1). (b) Let the PDF from part (a) be denoted as fylw). Suppose also in this case that w Write an expression for the joint PDF of w and y...
Let Y = Xβ + ε be the linear model where X be an n × p matrix with orthonormal columns (columns of X are orthogonal to each other and each column has length 1) Let be the least-squares estimate of β, and let be the ridge regression estimate with tuning parameter λ. Prove that for each j, . Note: The ridge regression estimate is given by: The least squares estimate is given by: We were unable to transcribe this...
The random vector Y = (Y1, ...,
Yn)T is such that Y = Xβ + ε, where X is an n
× p full-rank matrix of known constants, β is a p-length vector of
unknown parameters, and ε is an n-length vector of random
variables. A multiple linear regression model is fitted to the
data.
(a) Write down the multiple linear regression model assumptions in
matrix format.
(b) Derive the least squares estimator β^ of β.
(c) Using the data:...
1.Given the Multiple Linear regression model as Y-Po + β.X1 + β2X2 + β3Xs + which in matrix notation is written asy-xß +ε where -έ has a N(0,a21) distribution + + ßpXo +ε A. Show that the OLS estimator of the parameter vector B is given by B. Show that the OLS in A above is an unbiased estimator of β Hint: E(β)-β C. Show that the variance of the estimator is Var(B)-o(Xx)-1 D. What is the distribution o the...
2.10 Consider the linear system [.- '*"] E] [1+4+ek] where € is a small parameter to be specified. The exact solution is obviously for any value of e. Use a library routine based on Gaussian elim- ination to solve this system. Experiment with various values for e, especially values near Emach for your computer. For each value of e you try, compute an estimate of the condition number of the matrix and the relative error in each component of the...
Do I get the right answers? If not, can someone please
explain?
(a) 2 points possible (graded, results hidden) Consider a Gaussian linear model Y = aX + e in a Bayesian view. Consider the prior (a) = 1 for all a eR. Determine whether each of the following statements is true or false. (a) is a uniform prior. O True C False n(a) is a Jeffreys prior when we consider the likelihood L (Y = y|A = a, X...
Q4.. [40 points] Consider the multiple linear regression model given by y - XB -+ s, where y and e are vectors of size 8 × 1, X ls a matrix of size 8 x 3 and Disa vector of sze 3 × 1. Also, the following information are available e = 22 y -2 and XTy 3 1. [10 points) Estimate the regression coefficients in the model given above? 2. [4 points] Estimate the variance of the error term...