similar to: simple predict question

Displaying 20 results from an estimated 4000 matches similar to: "simple predict question"

2005 May 24
3
obtaining first and last record for rows with same identifier
I have a dataframe that contains fields such as patid, labdate, labvalue. The same patid may show up in multiple rows because of lab measurements on multiple days. Is there a simple way to obtain just the first and last record for each patient, or do I need to write some code that performs that. Thanks, Steven
2009 Jan 16
1
specifying model terms when using predict
I've recently encountered an issue when trying to use the predict.glm function. I've gotten into the habit of using the dataframe$variablename method of specifying terms in my model statements. I thought this unambiguous notation would be acceptable in all situations but it seems models written this way are not accepted by the predict function. Perhaps others have encountered this
2005 May 06
2
2 simple questions
Please excuse what I'm sure are very easy questions but I'm relatively new to the R environment. How can I view a range of list elements, but not all. e.g., I had a matrix of patients and then split them out by patient id. I know I can do patlist[[1]] to see the first one, but how can I view, say, the first ten patients? My other question is how to count how many patients have a
2005 Jun 09
2
Weibull survival modeling with covariate
I was wondering if someone familiar with survival analysis can help me with the following. I would like to fit a Weibull curve, that may be dependent on a covariate, my dataframe "labdata" that has the fields "cov", "time", and "censor". Do I do the following? wieb<-survreg(Surv(labdata$time, labadata$censor)~labdata$cov,
2013 Mar 18
1
try/tryCatch
Hi All, I have tried every fix on my try or tryCatch that I have found on the internet, but so far have not been able to get my R code to continue with the "for loop" after the lmer model results in an error. Here is two attemps of my code, the input is a 3D array file, but really any function would do.... metatrialstry<-function(mydata){ a<-matrix(data=NA, nrow=dim(mydata)[3],
2003 Jul 30
2
Comparing two regression slopes
Hello, I've written a simple (although probably overly roundabout) function to test whether two regression slope coefficients from two linear models on independent data sets are significantly different. I'm a bit concerned, because when I test it on simulated data with different sample sizes and variances, the function seems to be extremely sensitive both of these. I am wondering if
2005 Mar 09
1
multiple comparisons for lme using multcomp
Dear R-help list, I would like to perform multiple comparisons for lme. Can you report to me if my way to is correct or not? Please, note that I am not nor a statistician nor a mathematician, so, some understandings are sometimes quite hard for me. According to the previous helps on the topic in R-help list May 2003 (please, see Torsten Hothorn advices) and books such as Venables &
2006 May 06
2
How to test for significance of random effects?
Dear list members, I'm interested in showing that within-group statistical dependence is negligible, so I can use ordinary linear models without including random effects. However, I can find no mention of testing a model with vs. without random effects in either Venable & Ripley (2002) or Pinheiro and Bates (2000). Our in-house statisticians are not familiar with this, either,
2006 Nov 30
1
data.frame within a function (PR#9294) (cont'd)
This continues the message "data.frame within a function (PR#9294)" that was posted on 2006/10/12. Duncan Murdoch kindly replied. I'm using the current version R 2.4.0, but the same issue exists. Just copy and paste the following code under R, and compare the output of f1() and f2() and the output of f3() and f4(). Does anybody have any idea? Thanks.
2008 Sep 17
2
Command Prompt Question
Could someone please tell me how to stop the package/function name from being included before the command prompt? This started happening today after I made some changes to my Rprofile.site file and I don't know why. For example: if I enter example(AIC), instead of just getting the regular '>' before each output line, I get 'AIC>' instead. I only want the '>'
2006 Aug 23
1
covariance matrix of predictions
Hi ! I am trying to get at the covariance of the predictions of a linear model. Suppose the we have: > x<-runif(1000) > y<-2 + 25x*x +rnorm(1000) > lm1 <-lm(y~x, data = data.frame(y = y, x=x)) > x.pred <-runif(10) > y.hat <- predict(lm1, newdata = data.frame(x=x.pred)) I was wondering how to get an estimate of the covariance of y.hat which would be a 10 x 10
2009 Jan 28
1
gls prediction using the correlation structure in nlme
How does one coerce predict.gls to incorporate the fitted correlation structure from the gls object into predictions? In the example below the AR(1) process with phi=0.545 is not used with predict.gls. Is there another function that does this? I'm going to want to fit a few dozen models varying in order from AR(1) to AR(3) and would like to look at the fits with the correlation structure
2012 May 22
1
Adding Text to a Plot
Hi, all! I'm pretty sure I'm missing something about this. Is there a smart way of typping hat(R)^2 and it's value from a linear regression? I've just found this tricky one: # Sample data x <- sample(1:100,10) y <- 2+3*x+rnorm(10) # Run the regression lm1 <- lm(y~x) # Plotting plot(x,y, main="Linear Regression", col="red")
2013 Jan 18
1
Object created within a function disappears after the function is run
Dear R-helpers, I have run the code below which I expected to make an object called dd1, but that object does not exist. So, in summary, my problem is that my function is meant to make an object (dd1), and it does indeed make that object (I know that the last line of the function prints it out) but then, after the function has run, the object has disappeared. It's late on a Friday so I may
2010 Jun 17
1
Problems using allEffects() (package effect)
Dear R users, I have some trouble using the allEffects() function to compute and display effect plots for a linear model. My data is quite simple, it concerns effects of 3 treatments on the tumoral volume of mice. vTum codes for the qualitative initial volume, from small to big, temps is the time in month since beginning of treatment, and S?rie codes for the batch. Data is unbalanced. >
2005 Aug 22
1
plotting with same axes
I have used the 'par' command to overlay one plot on another. But how do I overlay it with the x-values plotted at the same points on the x-axis? Thank you, Steven
2005 May 05
2
efficient filtering of matrices
I was wondering if someone can tell me the best way to search through a matrix and choose certain rows (based on certain conditions) to put into a separate matrix. What I have tried so far is very slow for a large dataset I'm working with. e.g., I have this piece of code to create a new matrix (newmat) based on my filtering conditions. Do I need to do this kind of thing where I keep
2005 May 18
1
from list to dataframe
I was wondering if someone can help me figure out the following: I have two patient datasets, ds1 and ds2. ds1 has fields "patid", "date", and "lab1". ds2 has "patid", "date", and "lab2". I want to find all the patids that have at least 2 dated records for each lab. I started by splitting each dataset by patid, to create ds1.list
2010 Oct 12
1
delta AIC for models with 2 variables using MuMIn
Dear List, I want to ask a AIC question based on package library(MuMIn) The relative importance of 16 explanatory variables are assessed using delta AIC in a generalized linear model. Please kindly advise if it is possible to show models with any two only certain variables. Thank you. Elaine I asked a similar question and got a great help for models with only one variable as below.
2010 Aug 17
2
how to selection model by BIC
Hi All: the package "MuMIn" can be used to select the model based on AIC or AICc. The code is as follows: data(Cement) lm1 <- lm(y ~ ., data = Cement) dd <- dredge(lm1,rank="AIC") print(dd) If I want to select the model by BIC, what code do I need to use? And when to select the best model based on AIC, what the differences between the function "dredge" in