search for: ystar

Displaying 10 results from an estimated 10 matches for "ystar".

Did you mean: star
2001 Aug 30
1
MCMC coding problem
...t distribution # mu = mean of second mode # phi2 = multiplier of variance factor 2.38 # varwt = weight (0 < varweight <= 1) applied to variance of second part of mixture. # ntimes = number of iterations # # phi is the standard deviation of the proposal distribution. # y is the data matrix, ystar is the proposal state phi <- (2.38^2)/d * diag(phi2,d) y <- matrix(0,ncol=d,nrow=ntimes) ystar <- matrix(0,ncol=d,nrow=1) len <- ntimes/1000 - 1 meanmat <- matrix(0,nrow=len,ncol=d) quantmat <- array(0, dim = c(3,d,len)) count <- 0 # print("Comment out the browser before...
2006 Jan 19
2
Tobit estimation?
...s, Based on http://www.biostat.wustl.edu/archives/html/s-news/1999-06/msg00125.html I thought I should experiment with using survreg() to estimate tobit models. I start by simulating a data frame with 100 observations from a tobit model > x1 <- runif(100) > x2 <- runif(100)*3 > ystar <- 2 + 3*x1 - 4*x2 + rnorm(100)*2 > y <- ystar > censored <- ystar <= 0 > y[censored] <- 0 > D <- data.frame(y, x1, x2) > head(D) y x1 x2 1 0.0000000 0.86848630 2.6275703 2 0.0000000 0.88675832 1.7199261 3 2.7559349 0.38341782 0.6247869 4 0....
2012 Oct 25
2
How to extract auc, specificity and sensitivity
I am running my code in a loop and it does not work but when I run it outside the loop I get the values I want. n <- 1000; # Sample size fitglm <- function(sigma,tau){ x <- rnorm(n,0,sigma) intercept <- 0 beta <- 0 ystar <- intercept+beta*x z <- rbinom(n,1,plogis(ystar)) xerr <- x + rnorm(n,0,tau) model<-glm(z ~ xerr, family=binomial(logit)) int<-coef(model)[1] slope<-coef(model)[2] pred<-predict(model) result<-ifelse(pred>.5,1,0) accuracy<-length(whic...
2012 Oct 20
1
Logistic regression/Cut point? predict ??
...t various cut points; however, my output was garbage (at x equal zero, I did not get .50) I am basically testing the performance of classifiers. Here is the code: n <- 1000; # Sample size fitglm <- function(sigma,tau){ x <- rnorm(n,0,sigma) intercept <- 0 beta <- 5 * ystar <- intercept+beta*x* * z <- rbinom(n,1,plogis(ystar))* *# I believe plogis accepts the a +bx augments and return the e^x/(1+e^x) which is then used to generate 0 and 1 data* xerr <- x + rnorm(n,0,tau) # error is added here model<-glm(z ~ xerr, family=binomial(logit))...
2009 Apr 23
2
Two 3D cones in one graph
...<-t(G$vector%*%t(A)) E2<-t(diag(sqrt(G$values))%*%t(E1)) mu<-c(0.1,0.2) E3<-sweep(E2,2,-mu) a<-sqrt(max(rowSums(sweep(E3,2,mu)**2))) b<-sqrt(min(rowSums(sweep(E3,2,mu)**2))) astar<-as.numeric(a+abs(mu[1])) bstar<-as.numeric(b+abs(mu[2])) xstar<-seq(-astar,astar,len=50) ystar<-seq(-bstar,bstar,len=50) g<-expand.grid(x=xstar,y=ystar) p1<-2*g$x*mu[1]/a**2+2*g$y*mu[2]/b**2 p2<-(g$x**2/a**2+g$y**2/b**2) p3<-mu[1]**2/a**2+mu[2]**2/b**2-1 q<-(p1+sqrt(p1**2-4*p2*p3))/(2*p2) z<-sqrt(1-(q*g$x)**2-(q*g$y)**2) zstar<-(z/q) ind0<-!(q<1) g$z<-zsta...
2008 Sep 15
0
Simple censored quantile regression question
I start by doing a simple gaussian tobit by MLE: x1 <- runif(1000) # E() = 0.5 x2 <- runif(1000)*2 # E() = 1 x3 <- runif(1000)*4 # E() = 2 ystar <- -7 + 4*x1 + 5*x2 + rnorm(1000) # is mean 0 y <- ystar censored <- ystar <= 0 y[censored] <- 0 library(AER) m <- tobit(y ~ x1 + x2, left=0, data=D) summary(m) Which gives: Call: tobit(formula = y ~ x1 + x2, left = 0, data = D) Observations: Total Left-cen...
2002 Feb 11
0
profile
..., eta2)*log(Popn/PopStd) Ymax <- Ymax*PotYield3*Popn/1000 Ymax <- Ymax*ifelse(Dmax<=DIs*AWC, 1, 1 - beta*(Dmax -DIs*AWC)/SumEp) Nstar <- (Nsupply- MnmN*Ymax) / (OptN*Ymax - MnmN*Ymax) Nstar<-pmax ( 0,Nstar) Ystar<-ifelse(Nstar<1, (1 + gN*(1 - Nstar))* Nstar^(gN), 1) Ystar<-pmax ( 0, Ystar) Y.model <- Ystar*Ymax Y.model } # simulate experimental data for predictors nsim <- 300 Popn <- rnorm(nsim,PopStd,0.1*P...
2012 Sep 17
2
Problem with Stationary Bootstrap
Dear R experts,   I'm running the following stationary bootstrap programming to find the parameters estimate of a linear model:     X<-runif(10,0,10) Y<-2+3*X a<-data.frame(X,Y) coef<-function(fit){   fit <- lm(Y~X,data=a)    return(coef(fit)) }  result<- tsboot(a,statistic=coef(fit),R = 10,n.sim = NROW(a),sim = "geom",orig.t = TRUE)   Unfortunately, I got this
2008 Dec 16
1
Prediction intervals for zero inflated Poisson regression
...ro inflated poisson regression fm_zip <- zeroinfl(art ~ fem | 1, data = bioChemists) fit <- predict(fm_zip) Pearson <- resid(fm_zip, type = "pearson") VarComp <- resid(fm_zip, type = "response") / Pearson fem <- bioChemists$fem bootstrap <- replicate(999, { yStar <- pmax(round(fit + sample(Pearson) * VarComp, 0), 0) predict(zeroinfl(yStar ~ fem | 1), newdata = newdata) }) newdata0 <- newdata newdata0$fit <- predict(fm_zip, newdata = newdata, type = "response") newdata0[, 3:4] <- t(apply(bootstrap, 1, quantile, c(0.025, 0.975))) new...
2012 Oct 26
0
Problems getting slope and intercept to change when do multiple reps.
library(ROCR) n <- 1000 fitglm <- function(iteration,intercept,sigma,tau,beta){ x <- rnorm(n,0,sigma) ystar <- intercept+beta*x z <- rbinom(n,1,plogis(ystar)) xerr <- x + rnorm(n,0,tau) model<-glm(z ~ xerr, family=binomial(logit)) *int*<-coef(model)[1] *slope*<-coef(model)[2] # when add error you are suppose to get slightly bias slope. However when I change the beta in the origina...