Description Usage Arguments Note Examples
Set the y-values in a Cblmr object.
1 2 | ## S4 method for signature 'Cblmr'
sety( irWy )
|
irWy |
vector of y-values, pre-multiplied by the inverse of the square-root of 'weights' |
The pre-multiplied vector is more convenient as input during simulation tests. This vector is simply the y-vector if 'weights' is the default identity-matrix. The square-root of a matrix 'W' here is the matrix 'rW' such that rW*rW = W (not such that rW*transpose(rW) = W).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ## Data for Patient B from Smith and Cook (1980):
y= c(36.0, 45.5, 50.0, 60.0, 73.3, 71.0, 66.7, 60.0, 30.5, 18.3)
x= 1:10
sc <- blmr(y,x)
sc$ci()
newy= c(37.3, 47.1, 51.5, 67.6, 75.9, 73.3, 69.4, 61.5, 31.8, 19.4)
sc$sety(newy)
sc$ci()
## An example simulation test:
simtest <- function( x, theta, alpha, Bp, B, var, N =10000) {
y <- x
mod <- blmr(y,x) ## construct a 'blmr' object with arbitrary y values.
cat("\n Monte Carlo simulation test:\n")
cat("for model theta=",theta," alpha=",alpha," B'=",Bp," B=",B," var=",var,"\n")
cat("with observations at x=",x,"\n\n")
cat(" no. of coverage frequency of the 0.95-confidence interval by\n")
cat(" iterations CLR AF\n")
flush.console()
sigma = sqrt(var)
n = length(x)
countCLR = countAF = 0
for( i in seq(1,N) ) {
err <- rnorm(n,0,sigma)
for( j in seq(1,n) )
y[j] = alpha + Bp*min(x[j]-theta,0) + B*max(x[j]-theta,0) + err[j]
mod$sety(y)
stest = mod$sl(theta,"clr",.0001,FALSE)
if(stest>0.05) countCLR = countCLR + 1
stest = mod$sl(theta,"af",.0001,FALSE)
if(stest>0.05) countAF = countAF + 1
if(i/1000 - floor(i/1000) == 0) {
cat( format(i,width=10),
format(countCLR/i,digits=4,nsmall=4,width=22),
format(countAF/i,digits=4,nsmall=4,width=22), "\n" )
flush.console()
}
}
cat("\n")
}
x = c( 1.0, 1.1, 1.3, 1.7, 2.4, 3.9, 5.7, 7.6, 8.4, 8.6 )
simtest(x,3,0,-1,0.5,1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.