Displaying 15 results from an estimated 15 matches for "simdata".
2013 Apr 13
1
how to add a row vector in a dataframe
Hi,
Using S=1000
and
simdata <- replicate(S, generate(3000))
#If you want both "m1" and "m0" #here the missing values are 0
res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1})
res1[,997:1000]
#????? [,1]???????? [...
2011 Dec 05
1
RcppArmadillo compilation error: R CMD SHLIB returns status 1
...AMPLE ###
suppressMessages(require(RcppArmadillo))
suppressMessages(require(Rcpp))
suppressMessages(require(inline))
code <- '
arma::mat coeff = Rcpp::as<arma::mat>(a);
arma::mat errors = Rcpp::as<arma::mat>(e);
int m = errors.n_rows; int n = errors.n_cols;
arma::mat simdata(m,n);
simdata.row(0) = arma::zeros<arma::mat>(1,n);
for (int row=1; row<m; row++) {
simdata.row(row) = simdata.row(row-1)*trans(coeff)+errors.row(row);
}
return Rcpp::wrap(simdata);
'
## create the compiled function
rcppSim <- cxxfunction(signature(a="numeric&...
2009 Dec 31
4
Obtaining partial output from a function that does not run to completion.
...n't get the output from either the lm() or vf() even thought neither lm() nor vif() have any problems . How can I force the function to print sequential results rather than wait for the entire function to complete before listing the functhion's output?
Thanks,
John
minBMI<-function(SS,SimData)
{
SampleData<-sample(1:SS,size=SS,replace=TRUE)
fitBMIEpiRevlm<-lm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],x=TRUE)
print(summary(fitBMIEpiRevlm))
print(vif(fitBMIEpi...
2010 Aug 31
1
cannot allocate vector of size 381.5 Mb
...ead some posts from the mailing list on the same problem, but it seems
that i still cannot solve this problem.
I only want to generate some simulated data.
#Generate 2500 observations-it works without errors
> coords<-as.matrix(expand.grid(seq(0,100,length.out=50),
seq(0,100,length.out=50)))
#SimData is a user-written function
> SimBinData<-SimData(n=2500,coords=coords, x.mu=c(0,1),covar.cor=matrix(c(1,0.25,0.25,1),
2, 2),beta=c(1,0.5,5))
#Generate 10000 observations-errors appeared
#Following some posts, i set the memory to the maximum value. But i still
got errors.
> memory.limit(siz...
2009 Dec 30
1
glm error: cannot correct step size
...en I drop one independent variable, the model runs fine. Can anyone help me understand what the error means and how I can correct it?
Thank you,
John
> fit11<-glm(AAMTCARE~BMI+BMIsq+SEX+jPHI+jMEDICAID+factor(AgeCat)+
+ factor(jINDINC)+jMARSTAT+jEDUCATION+factor(jsmokercat)+factor(jrace),data=SimData,family=Gamma(link="log"))
Warning: step size truncated due to divergence
Error in glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, :
inner loop 1; cannot correct step size
# Drop factor(jrace) and model runs without a problem.
> fit11<-glm(AAMTCARE~B...
2009 Dec 09
1
Why cannot get the expected values in my function
Hi,
In the following function, i hope to save my simulated data into the
"result" dataset, but why the final "result" dataset seems not to be
generated.
#Function
simdata<-function (nsim) {
result<-matrix(NA,nrow=nsim,ncol=2)
colnames(result)<-c("x","y")
for (i in 1:nsim) {
set.seed(i)
result[i,]<- cbind(runif(1),runif(1))
}
return(result)
}
#simulation
> simdata(10) #correct result
x y
[1,] 0.26...
2006 Mar 16
1
lme4/Matrix: Call to .Call("mer_update_y"...) and LMEoptimize gives unexpected side effect...
...arlo p-values in lmer-models based on sampled data sets. To speed up calculations, I've tried to use internal functions from the Matrix package (as suggested ealier on the list by Doug Bates).
So I did:
fm2 <- lmer(resistance ~ ET + position + (1|Grp), Semiconductor,method='ML')
simdata<-simulate(fm2,nsim=1)
ynew <- simdata[,1]
mer <- fm2
.Call("mer_update_y", mer, ynew, PACKAGE = "Matrix")
mer1u <- LMEoptimize(mer, lmerControl(mer))
What puzzles me is that this call alters my original model fm2 as some kind of side effect. In fact, after the...
2006 Aug 31
3
what's wrong with my simulation programs on logistic regression
...t;")) #8 independent variables,x1-x8;
#logistic regression model is logit(y)=x1+x2+x3+x4+x5+x6+x7+x8
data$y<-exp(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)/(1+(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8))
logist<-glm(y~.,family=binomial(),data=simdata)
*Warning messages:*
1: algorithm can't converge in: glm.fit(x = X, y = Y, weights = weights,
start = start, etastart = etastart,
2: the probability is 0 or 1 in: glm.fit (x = X, y = Y, weights = weights,
start = start, etastart = etastart,
--
With Kind Regards,
Zhi Jie,Zhang ,PHD
Department o...
2006 Aug 02
0
Trying to use segmented in a function
...). I am using segmented to do the breakpoint
regression: this package seems to be the one that most people use for
this, as far as I can see.
Since I want to run some simulations, I'm trying to write functions
that use segmented, and it's driving me mad. Here's a simple example:
simdata<-function
(Ns=200,Xmean=20,Xsd=5,SdYerr=0.5,Yint=0,threshold=20,slopebelow=0.5,slo
peabove=1)
{
Xs<-rnorm(Ns,Xmean,Xsd)
Yerr<-rnorm(Ns,0,SdYerr)
D<-ifelse(Xs<=threshold,0,1)
XminusX0<-Xs-threshold
Ys<-Yint+slopebelow*Xs+slopeabove*XminusX0*D+Yerr
plot(Xs,Ys)
linmod&...
2009 Jan 13
3
problem whit Geneland
I do the these passages:
library(Geneland)
set.seed(1)
data <- simdata(nindiv=200,
coord.lim=c(0,1,0,1) ,
number.nuclei=5 ,
allele.numbers=rep(10,20),
IBD=FALSE,
npop=2,
give.tess.grid=FALSE)
geno <- data$genotypes
coord <- t(data$coord.indiv)
path.mcmc <- paste(...
2013 May 29
3
bootstrap
Hi,
You might need to check library(boot).? I have never used that before.? So, I can't comment much.? It is better to post on R-help list.? I had seen your postings on Nabble in the past.? Unfortunately those postings were not accepted in R-help.? You have to directly post at ? r-help at r-project.org after registering at:
https://stat.ethz.ch/mailman/listinfo/r-help
?
2010 Jan 02
1
Help with tryCatch
...in"))
# set row counter
n<-0
# Function to run
testone<-function()
{
SampleData<-sample(1:SS,size=SS,replace=TRUE)
result<-summary(glm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],family=Gamma(link="log")))
}
# if function ran correctly, increment row counter by one and store results
# Do this 10 times
while (n<10) {
result<-tryCatch(testone(),final=n<-n+1)
# Do the function ran without an error
result
coeffs[n,1] <- result$coeffici...
2004 May 25
0
RMySQL problem - SOLVED
Hi,
The problem was the row.names that were sent to the database and created
an primary key duplicate. Now it works fine.
BTW congratulations for the package. It copied 15300 rows by 11 columns
in less than 5 seconds, in my PIII 833 with 1 GB RAM.
> system.time(dbWriteTable(con, "TBL_SIMDATA", TBL.SIMDATA, append =
TRUE, row.names=F))
[1] 3.87 0.05 4.86 0.01 0.00
Just one suggestion. It would be usefull to have a more verbose output,
maybe the "LOAD DATA INFILE" output.
Thanks for your help.
EJ
On Tue, 2004-05-25 at 13:01, Sean Davis wrote:
> I have written ta...
2008 Sep 07
1
an error to call 'gee' function in R
...1, ?0 = 3, and n = 50.
For each 1 ? i ? n,
Simulate xi from N (1, 1).
Simulate zi0 and zit from
zi0 follows i.d. Poisson (?0) ,
zit | xi follows i.d. Poisson (?it) , 1 ? t ? 3,
log (?it) = log(E (zit | xi)) = ?0t + xi?1t = 1+xi.
Let yit = zi0 + zit, 1 ? t ? 3.
So my data frame, let me call it 'simdata', the first 10 rows look like this:
id y.1 y.2 y.3 x
1 3 5 6 -0.06588626
2 6 7 6 -0.08265981
3 6 8 13 0.58307719
4 22 21 28 2.21099940
5 5 12 8 1.06299869
6 8 21 24 1.47615784
7 11 8 9 0.83748390
8 16 15 16 1.6701131...
2005 Apr 11
0
correlation range estimates with nlme::gls
...diagnostics of
non-convergence etc.? (Reported AIC values suggest that the models with
autocorrelation *are* preferable, by quite a bit -- I could pursue this
further.) Or should I just not worry about it and move on?
Ben Bolker
--------------------------
simulation code:
library(MASS)
simdata <- function(sd=200,range=2,n=NULL,mmin=0) {
if (is.null(n)) mile <- seq(mmin,17.5,by=0.5) else {
mile <- seq(mmin,17.5,length=n)
}
mean <- 3000-50*(mile-10)^2
v <- sd^2
dist <- abs(outer(mile,mile,"-"))
Sigma <- v*exp(-dist/range)
X <- mvr...