[R] contourplot lines, text, and mtext

2007-09-06 Thread Richard D. Morey
If I have a contourplot (in the lattice package) and I want to add 
straight lines to it, how do I do this?

I see that there are llines() and lsegement() functions for lattice 
plots, but they don't seem to do anything in this case:

library(lattice)
library(KernSmooth)
x=rnorm(1)
y=x+rnorm(x,0,.5)
a=bkde2D(cbind(x,y),.7)
z=as.vector(a$fhat)
grid=expand.grid(x=a$x1,y=a$x2)
grid$z=z
contourplot(z~x*y,data=grid,region=T,col.regions=gray(seq(1,0,len=255)),colorkey=T,cuts=50,contour=F)
llines(x=c(-5,5),y=c(-5,5))
  NULL
lsegments(x0=-5,y0=-5,x1=5,y1=5)

I'm just trying to do the equivalent of abline(0,1) on the plot.

ltext(), on the other hand, seems to like to place text in the upper 
left corner of the plot. I suspect that I misunderstand the coordinate 
system that lattice uses for contour plots. Can anyone enlighten me?

Richard


-- 
Richard D. Morey, M.A.
Research Assistant, Perception and Cognition Lab
University of M
issouri-Columbia

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] half-logit and glm (again)

2007-08-10 Thread Richard D. Morey
I know this has been dealt with before on this list, but the previous 
messages lacked detail, and I haven't figured it out yet.

The model is:

\x_{ij} = \mu + \alpha_i + \beta_j

\alpha is a random effect (subjects), and \beta is a fixed effect 
(condition).

I have a link function:

p_{ij} = .5 + .5( 1 / (1 + exp{ -x_{ij} } ) )

Which is simply a logistic transformed to be between .5 and 1.

The data y_{ij} ~ Binomial( p_{ij}, N_{ij} )

I've generated data using this model, and I'd like to fit it. My data is 
a data frame with 3 columns, response (0/1), subject (a factor), and 
condition (another factor).

Here is my link definition:
#
halflogit=function(){
half.logit=function(mu) qlogis(2*mu-1)
half.logit.inv=function(eta) .5*plogis(eta)+.5
half.logit.deriv=function(eta) .5*(exp(eta/2)+exp(-eta/2))^-2
half.logit.inv.indicator=function(eta) TRUE
half.logit.indicator=function(mu) mu.5  mu1
link - half.logit
structure(list(linkfun = half.logit, linkinv = half.logit.inv,
mu.eta = half.logit.deriv, validmu = 
half.logit.indicator ,valideta = half.logit.inv.indicator, name = link),
   class = link-glm)
}

binomial(halflogit())

Family: binomial
Link function: half.logit
#

I based this off the help for the family() function.

So I try to call glmmPQL (based on other R-help posts, this is the 
easiest to use?)

#
glmmPQL(response ~ condition, random = ~ 1|subject, family = 
binomial(halflogit()), data = dat)

Error in if (!(validmu(mu)  valideta(eta))) stop(cannot find valid 
starting values: please specify some) :
 missing value where TRUE/FALSE needed
In addition: Warning message:
NaNs produced in: qlogis(p, location, scale, lower.tail, log.p)

#

It looks like I've misdefined something and it is going outside the 
specified domains for the functions. I can't find any reference to 
starting starting values in help for glmmPQL() or lme().

  If anyone has any working code where they've done a user defined link 
function, it would be greatly appreciated.


Thanks,
Richard

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] error code 5 from Lapack routine 'dsyevr'

2007-03-15 Thread Richard D. Morey
While using the rmvnorm function, I get the error:

Error in eigen(sigma, sym = TRUE) : error code 5 from Lapack routine 
'dsyevr'

The same thing happens when I try the eigen() function on my covariance 
matrix. The matrix is a symmetric 111x111 matrix. Well, it is almost 
symmetric; there are slight deviations from symmetry (the largest is 
3e-18).  I have this in an MCMC loop, and it happens about once in every 
40 iterations or so.

What does this error mean?

Thanks.


-- 
Richard D. Morey, M.A.
Research Assistant, Perception and Cognition Lab
University of Missouri-Columbia

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.