similar to: sampling from a mixture distribution

Displaying 20 results from an estimated 800 matches similar to: "sampling from a mixture distribution"

2006 Mar 08
2
fitting a distribution using glm
it is easy to fit a distribution using fitdistr poisdata <- rpois(n = 100, lambda = 2) poismle <- fitdistr(poisdata, "Poisson") poismle but i would like to know whether its possible to get an identical result using glm. I use poistab <- data.frame(table(poisdata)) colnames(poistab) <- c("width","freq"); poistab[,"width"] <-
2004 Mar 25
3
subsetting based on vector
Dear R users; I am trying to write a small program which reads in a data set, and selects observations from certain years before the analysis. I have a problem including the selection criteria in the header of the program. Here is the problem; dataFIT<-function(MODEL, MARGINS, yearConsidered){ library(foreign CovPaper<-read.spss("C:/Data/data.sav") NewData <-
2007 Jun 20
2
"xtable" results doesn't correspond to data.frame
Dear useRs, Am trying to use xtable on the following data.frame and I don't get what I expect: example.table <- data.frame(rbind( c("Gender"," "," "," "), cbind(rep(" ",2),c("Male","Female"),c(3.0,4.0),c(3/7,4/7)) )) colnames(example.table) <- c(" "," ","number of
2005 Aug 04
2
drawing a network digraph
Dear R users, I have a matrix with 2 columns with the variables: "daughter index", "mother index". I would like to draw a network digraph using this data, where each daughter is connected to a mother and between the connections inlcude a circle with the information on the indices ("daughter index", "mother index"): i.e. something similar to graphs
2012 Dec 03
1
How do I make R randomForest model size smaller?
I've been training randomForest models on 7 million rows of data (41 features). Here's an example call: myModel <- randomForest(RESPONSE~., data=mydata, ntree=50, maxnodes=30) I thought surely with only 50 trees and 30 terminal nodes that the memory footprint of "myModel" would be small. But it's 65 megs in a dump file. The object seems to be holding all sorts of
2003 Jan 22
1
something wrong when using pspline in clogit?
Dear R users: I am not entirely convinced that clogit gives me the correct result when I use pspline() and maybe you could help correct me here. When I add a constant to my covariate I expect only the intercept to change, but not the coefficients. This is true (in clogit) when I assume a linear in the logit model, but the same does not happen when I use pspline(). If I did something similar
2003 Jun 16
1
Hmisc multiple imputation functions
Dear all; I am trying to use HMISC imputation function to perform multiple imputations on my data and I keep on getting errors for the code given in the help files. When using "aregImpute" the error is; >f <- aregImpute(~y + x1 + x2 + x3, n.impute=100) Loading required package: acepack Iteration:1 Error in .Fortran("wclosepw", as.double(w), as.double(x),
2004 May 27
2
manipulating elements of a vector
Dear R users; I would like to convert a series of vectors to matrices in the following way; (2,1,1) to a matrix 1 0 0 1 0 0 0 1 0 0 0 1 The idea is that the column sum of the matrix should be equal to the elements of the vector. Thanks. Vumani
2003 Jan 17
2
Re: Universal legend in plot
Dear R-users: I asked a question on how I can have a universal legend in a plot and received the following result. I tried using "layout" but I can't seem to work on the "empty" plot (where I have to have the legend). I tried "oma" but I couldn't improve the quality of the plot, and that I didn't know how to specify all the line types using the
2003 May 09
1
manipulating elements of a matrix
Dear R users: I have the following matrix. 0 1 1 0 1 0 2 1 0 3 0 0 I would like to spread the matrix such that whenever the row sum is greater than 1 the row is repeated the number of times given by the row sum. Furthermore I would like to split the following cases: 0 1 1 such that it map to the following matrix 0 1 0 0 0 1 such that each row adds up to 1. I have no problems with cases
2010 Dec 11
1
randomForest: help with combine() function
I've built two RF objects (RF1 and RF2) and have tried to combine them, but I get the following error: Error in rf$votes + ifelse(is.na(rflist[[i]]$votes), 0, rflist[[i]]$votes) : non-conformable arrays In addition: Warning message: In rf$oob.times + rflist[[i]]$oob.times : longer object length is not a multiple of shorter object length Both RF models use the same variables, although
2005 Nov 21
2
Multinomial Nested Logit package in R?
Dear R-Help, I'm hoping to find a Multinomial Nested Logit package in R. It would be great to find something analogous to "PROC MDC" in SAS: > The MDC (Multinomial Discrete Choice) procedure analyzes models > where the > choice set consists of multiple alternatives. This procedure > supports conditional logit, > mixed logit, heteroscedastic extreme value,
2005 Jun 01
1
"\n" in legend using substitute and as.expression
Dear R users, Is it possible to force a hard return in an expression. I tried including one for a legend using an expression and it didn't work. Here is my code, legend(12, 0.10, c("Fitted density", as.expression(substitute(paste("Weibull (", alpha==shapeU," , ", beta==scaleU,") Mean = ",meanU," days"), list(shapeU =
2003 Jan 20
1
R analogue
Dear R users: Is there any R analogue for the S+ function "na.gam.replace". I would like to make an interaction of a categorical and smooth continuous covariate. Thanks. Vumani Dlamini Central Statistical Office Swaziland
2006 Jun 29
1
using "rbinom" in C code gives me erroneous results... random variable is not random (always zero)...
Dear Listers, I am trying to use "rbinom" in my C code, but i always get zeros as output no matter the probability. Am not sure what I am doing wrong because the function has worked before. Attached in an example. Noticed that "rbinom" expects 'n' to be REAL. Regards, Vumani R 2.3.1 (2006-06-01) Windows XP Gcc /* Called this file binom.c and then ran rcmd shlib on it
2006 Jul 05
1
i suspect that there a memory leak in "vmmin"?
Dear listers, Am currently using MCMC approaches to estimate some parameters of my model. One parameter has to be updated using a tuned gamma distribution. So at each iteration I estimate the mean and variance of the density of the gamma approximation using "vmmin" (i also supply the gradient argument). For moderate replications the procedure works, but if I increase them R crashes.
2003 Aug 20
1
query on converting survey data from one structure to another
Dear R users, I am trying to convert a dataset from one format to several rectangular datasets. A consultant helped design the data entry program for our survey using Delphi/Pascal and for each household the information is stored in a file called "EA-HM-HH.TXT" where EA is the enumeration area number, HM is the homestead number and HH is the household number. Within this file the
2010 Jul 18
2
loop troubles
Hi all, I appreciate the help this list has given me before. I have a question which has been perplexing me. I have been working on doing a Bayesian calculating inserting studies sequentially after using a non-informative prior to get a meta-analysis type result. I created a function using three iterations of this, my code is below. I insert prior mean and precision (I add precision manually
2013 Mar 30
1
normal mixture EM not working?
Hi, I am currently working on fitting a mixture density to financial data. I have the following data: http://s000.tinyupload.com/?file_id=00083355432555420222 I want to fit a mixture density of two normal distributions. I have the formula: f(l)=πϕ(l;μ1,σ21)+(1−π)ϕ(l;μ2,σ22) my R code is: normalmix<-normalmixEM(dat,k=2,fast=TRUE) pi<-normalmix$lambda[1] mu1<-normalmix$mu[1]
2006 Sep 28
1
Nonlinear fitting - reparametrization help
Hi, I am trying to fit a function of the form: y = A0 + A1 * exp( -0.5* ( (X - Mu1) / Sigma1 )^2 ) - A2 * exp ( -0.5* ( (X-Mu2)/Sigma2 )^2 ) i.e. a mean term (A0) + a difference between two gaussians. The constraints are A1,A2 >0, Sigma1,Sigma2>0, and usually Sigma2>Sigma1. The plot looks like a "Mexican Hat". I had trouble (poor fits) fitting this function to toy data