I have a problem with boxcoxfit function.
I simulated some data and now I want to create estimators for regression parameters and parameter in box-cox transformation.
I use a package geoR
I have a matrix X with 2 columns and Y with not-negative values (which I get by inverse transformation of box-cox).
I use a boxcoxfit(Y~X)
and the answer has 4 parameters (one extra for intercept). When I add intercept to mz matrix X, and run the boxcosfit again, for lambda=2, I get a nonsence estimator for the intercept.
Here is my full code:
library(geoR)
#optional
set.seed(80974140)
XX=matrix(rnorm(2000,100,12),ncol=2,nrow=1000)
epsilon=rnorm(1000,0,1)
beta=c(0,2,3)
a=2
#invers transformation
inverz=function(y,a){
if (a==0) inverz<-exp(y)
else inverz<-(y*a+1)^(1/a)
return(inverz)
}
jedna=rep(1,1000)
X=cbind(jedna,XX) #intercept
TY=X%*%beta+epsilon #regression model
head(cbind(TY,X))
Y=inverz(TY,a) #Observed data
summary(Y)
head(cbind(Y,X,epsilon))
boxcoxfit(object=Y,xmat=X)
And the output:
Fitted parameters:
lambda beta0 beta1 beta2 sigmasq
1.9903028 2.0598958 1.9415787 2.8965162 0.9945854 `
Can I substract somehow the intercept form the boxcoxfit?
Can I get estimate std. deviation for the coefficients?
Thanks for your answers
PS: Sorry for my bad English