similar to: mapply, coxph, and model formula

Displaying 20 results from an estimated 5000 matches similar to: "mapply, coxph, and model formula"

2007 Nov 09
2
wrapper for coxph with a subset argument
Dear R-help - Thanks to those who replied yesterday (Christos H. and Thomas L.) regarding my question on coxph and model formula, the answers worked perfectly. My new question involves the following. I want to run several coxph models (package survival) with the same dataset, but different subsets of that dataset. I have found a way to do this, described below in functions subwrap1 and
2010 Sep 18
0
Saving long character variable to database saves timestamp instead
When saving a data frame with long character variable, approximately longer than 30000 characters, to a text field in PostgreSQL, using RODBC on Windows XP, I get a timestamp saved to the database instead. Is there any way to extend the number of characters that a text variable can receive? Here are the details of my case (simplified): I'm using PostgreSQL to create a table CREATE TABLE
2009 Apr 24
2
argument 'exclude' in function xtabs
Dear all I was willing to use argument 'exclude' in function xtabs to remove some levels of factors (xtabs help page says '"exclude: a vector of values to be excluded when forming the set of levels of the classifying factors"). I tried: > mydata <- data.frame( treatment = c("B", "A", "C", "C", "B",
2011 Apr 20
2
survexp with weights
Hello, I probably have a syntax error in trying to generate an expected survival curve from a weighted cox model, but I can't see it. I used the help sample code to generate a weighted model, with the addition of a "weights=albumin" argument (I only chose albumin because it had no missing values, not because of any real relevance). Below are my code with the resulting error
2012 Nov 26
1
Plotting an adjusted survival curve
First a statistical issue: The survfit routine will produce predicted survival curves for any requested combination of the covariates in the original model. This is not the same thing as an "adjusted" survival curve. Confusion on this is prevalent, however. True adjustment requires a population average over the confounding factors and is closely related to the standardized
2010 Aug 11
4
Arbitrary number of covariates in a formula
Hello! I have something like this: test1 <- data.frame(intx=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x1=c(0,2,1,1,1,0,0), x2=c(1,1,0,0,2,2,0), sex=c(0,0,0,0,1,1,1)) and I can easily fit a cox model: library(survival) coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1) However, I want to
2007 May 17
1
MICE for Cox model
R-helpers: I have a dataset that has 168 subjects and 12 variables. Some of the variables have missing data and I want to use the multiple imputation capabilities of the "mice" package to address the missing data. Given that mice only supports linear models and generalized linear models (via the lm.mids and glm.mids functions) and that I need to fit Cox models, I followed the previous
2008 May 16
2
Integer / floating point question
Dear R-help - I have thought about this question for a bit, and come up with no satisfactory answer. Say I have the numeric vector t1, given as t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0) I simply want to reliably extract the unique integers from t1, i.e., the vector c(1, 2, 3). This is of course superficially simple to carry out. However, my question is related to R FAQ 7.31, "Why
2008 Feb 26
1
wrapper for save function
Hello - I would like to create a wrapper to the 'save' function in the base package, but have a small problem with the name of the object that is getting saved in the file. Below is a simple example illustrating my problem. ## BEGIN SAMPLE R CODE ################################################## ## Here is the wrapper for the save function
2010 Jul 28
2
Axes=F and plotting dual y axes
Howdy. Been running into a bit of trouble with plotting. Seems that axes=F is not "working". Whenever I plot (either a dataframe or xts/zoo series) and I set axes=F along with xlab/ylab="" I still get the default axes printed in my chart. Consider this: #Create some sample data, both 50 units of blah series2 = c(1:50) series1 = rep(25:74) testdf1 = as.data.frame(series1)
2005 Oct 24
1
Error in step() (or stepAIC) for Cox model
Hello all, I am trying to use stepwise procedure to select covariates in Cox model and use bootstrap to repeat stepwise selection, then record how many times variables are chosen by step() in bootstrap replications. When I use step() (or stepAIC) to do model selection, I got errors. Here is the part of my code for (j in 1:mm){ #<--mm=10 for (b in 1:nrow(reg.bs)){ #<--bootstrap 10
2009 Apr 27
3
Formatting numbers
I've been trough the R documentation for about half an hour and it's not clear to me how to do this: I need to format to character a series of integers from 1 to 1000, and I like them to look like "0001" "0002", "0059", "0123" and so on. Padded with zeroes to have four digits. Cheers! Mario. r-help-request at r-project.org wrote: > Send
2006 Sep 03
2
Running cox models
Hi, I'm reading van Belle et al "Biostatistics" and trying to run a cox test using a dataset from: http://faculty.washington.edu/~heagerty/Books/Biostatistics/chapter16.html (Primary Biliary Cirrhosis data link at top of the page), I'm using the following code: --------------- start of code library(survival) liver <-
2011 Apr 01
2
Cox Proportional Hazards model with a time-varying covariate
Hello Everyone,   I'm learning how to perform various statistical analyses in R. I'm checking my understanding by replicating examples from my SAS books. Below is an attempt to replicate a Cox Proportional Hazards model with a time-varying covariate. I think I'm doing this correctly but am not completely sure. I would appreciate it if someone could double-check my results. In case
2006 Apr 04
1
Indexing a vector by a list of vectors
Hello R-help - I have vec <- c("string1", "string2", "string3") ind <- list(c(1,2),c(1,2,3)) I want "vec" indexed by each vector in the list "ind". The first element of the list I want would be vec[c(1,2)], the second element would be vec[c(1,2,3)], like the following. [[1]] [1] "string1" "string2" [[2]] [1]
2010 Sep 13
0
using survexp and ratetable with coxph object that includes a factor term
Hello, I'm attempting to use the ratetable argument to survexp in the survival package. I use the example from the ?survexp help page below, and then slightly modify it to produce an error. library(survival) data(pbc) #fit a model without any factors pfit1 <- coxph(Surv(time, status > 0) ~ trt + log(bili) + log(protime) + age + platelet, data=pbc) #this works as expected
2008 Nov 24
1
Discrepancy in the PBC data set
The data set in R is wrong. I've found mistakes on 2 lines in a quick look. I don't know if the data is incorrect in the Appendix of Fleming and Harrington as well (someone seems to have borrowed my copy), which is where the data set appears to have been taken from, given all the "-9" codes in it. (Note, Tom Fleming originally got the data from me, so I'm fairly
2008 Mar 23
1
mapply
In an earlier post, a person wanted to divide each of the rows of rawdata by the row vector sens so he did below but didn't like it and asked if there was a better solution. rawdata <- data.frame(rbind(c(1,2,2), c(4,5,6))) sens <- c(2,4,6) temp <- t(rawdata)/sens temp <- t(temp) print(temp) Gabor sent three other solutions and I understood 2 of them but not the
2003 Oct 14
3
mapply() gives seg fault
Hello everybody. I've been experimenting with mapply(). Does anyone else have problems with: R> mapply(rep,times=1:4, MoreArgs=42) (I get a seg fault). robin R> R.version _ platform powerpc-apple-darwin6.6 arch powerpc os darwin6.6 system powerpc, darwin6.6 status beta major 1 minor 8.0 year 2003 month 10 day 02 language R >
2011 Jul 31
1
Trouble Using mapply
Dear all, I am having a problem with mapply. I guess the reason is that mapply is not "vectorized". But could you please take a look at my code below and help me to find a solution (either a better way to use mapply or a different function to call). Thanks a lot! ##beginning of my code myfun <- function(threshold, all.data) { ##Just a demostration of a function that takes a