Replace underlying standard errors in lm() OLS model in R -


i run ols model using lm() in r , replace standard errors in model. in following example, replace each standard error "2":

set.seed(123) x <- rnorm(100) y <- rnorm(100)  mod <- lm(y ~x)  ses <- c(2,2) coef(summary(mod))[,2] <- ses sqrt(diag(vcov(mod))) <- ses 

any thoughts on how this? thanks.

those assignments not going succeed. coef, sqrt , vcov not going pass values "upstream". this:

> false.summ <- coef(summary(mod)) > false.sqrt.vcov <- sqrt(diag(vcov(mod)))  > false.summ                estimate std. error    t value  pr(>|t|) (intercept) -0.10280305 0.09755118 -1.0538371 0.2945488 x           -0.05247161 0.10687862 -0.4909459 0.6245623 > false.summ[ , 2] <- ses > false.sqrt.vcov (intercept)           x   0.09755118  0.10687862  > false.sqrt.vcov <- ses 

you modify summary-object @ least coef-matrix, there no "vcov" element in summary despite fact vcov return value.

> summ <- summary(mod) > summ$coefficients[ , 2] <- ses > coef(summ)                estimate std. error    t value  pr(>|t|) (intercept) -0.10280305          2 -1.0538371 0.2945488 x           -0.05247161          2 -0.4909459 0.6245623  > summ$vcov null > vcov(summ)              (intercept)           x (intercept)  0.009516233 -0.00103271 x           -0.001032710  0.01142304: 

if wanted change output of vcov when applied summary object need distort unscaled cov-matrix. code vcov uses object-class:

> getanywhere(vcov.summary.lm) single object matching ‘vcov.summary.lm’ found found in following places   registered s3 method vcov namespace stats   namespace:stats value  function (object, ...)  object$sigma^2 * object$cov.unscaled <bytecode: 0x7fb63c784068> <environment: namespace:stats> 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -