Using following code to run a quantile regress for mixed effect, unable to make the function QRLMM.
First, I installed package "qrLMM", but when trying to load the package, the error message reminds there is no package called ‘tlrmvnmvt’, here is the entire message when run library(qrLMM):
library(qrLMM)
Error: package or namespace load failed for ‘qrLMM’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘tlrmvnmvt’
In addition: Warning message:
package ‘qrLMM’ was built under R version 4.1.3
When tried to install tlrmvnmvt, it says it is not available, the error message listed below, can anyone help fix the problem?
install.packages("tlrmvnmvt")
Installing package into ‘C:/Users/jxzou/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘tlrmvnmvt’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
#Using the Orthodontic distance growth data
data(Orthodont)
attach(Orthodont)
y = distance #response
x = cbind(1,c(rep(0,64),rep(1,44)),age) #design matrix for fixed effects
z = cbind(1,age) #design matrix for random effects
groups = Subject
model = QRLMM(y,x,z,groups,MaxIter=200)
beta = model$res$beta #fixed effects
weights = model$res$weight #random weights
nj = c(as.data.frame(table(groups))[,2]) #obs per subject
fixed = tcrossprod(x,t(beta))
random = rep(0,dim(x)[1]) #initializing random shift
for (j in 1:length(nj)){
z1=matrix(z[(sum(nj[1:j-1])+1):(sum(nj[1:j])),],ncol=dim(z)[2])
random[(sum(nj[1:j-1])+1):(sum(nj[1:j]))] = tcrossprod(z1,t(weights[j,]))
}
pred = fixed + random #predictions
group.plot(age,pred,groups,type = "l")
group.points(age,distance,groups)
Above code was copied from example here:
https://rdrr.io/cran/qrLMM/man/QRLMM.html
Thank you!