Skip to content
Back to formatted view

Raw Message

Message-ID: <39B6DDB9048D0F4DAD42CB26AAFF0AFA076E3F@usctmx1106.merck.com>
Date: 2005-04-22T13:25:49Z
From: Liaw, Andy
Subject: lsfit result - how to compute t-values for coefficients

You can try something like:

fit <- lsfit(X, array(Y, dim = c(t.length, prod(d.dim[2:4])))) 
rsq <- sapply(ls.print(fit, print.it=FALSE)$coef.table,
              function(x) x[-1,c(1, 3)])
dim(rsq) <- c(ncol(X), 2, dim(rsq)[2])
dimnames(rsq) <- list(NULL, c("Estimate", "t-value"), prod(d.dim[2:4]))

HTH,
Andy

> From: Christoph Lehmann
> 
> Hi
> I used lsfit instead of lm since I have a huge Y data-set (X being 
> constant for all Y).
> 
> Since I require the t-values for all coefficients: which would be the 
> fastest way to compute them, eg for the example:
> 
> ## using lsfit with a matrix response:
> t.length <- 5
> d.dim <- c(t.length,7,8,9) # dimesions: time, x, y, z
> Y <- array( rep(1:t.length, prod(d.dim)) + rnorm(prod(d.dim), 
> 0, 0.1), 
> d.dim)
> X <- cbind(c(1,3,2,4,5), c(1,1,1,5,5))
> 
> date()
> rsq <-lsfit(X, array(c(Y), dim = c(t.length, 
> prod(d.dim[2:4]))))$coef[2,] #coef for first non-const pred
> names(rsq) <- prod(d.dim[2:4])
> rsq <- array(rsq, dim = d.dim[2:4])
> date()
> 
> what would be the best way to get the t-value for all coef,
> not only (as above illustrated for the beta value) for one 
> predefined coef?
> 
> ##-----
> 
> many thanks
> christoph
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>