Error In Tune * V Non-conformable Arguments
♦ ♦ | Report Content as Inappropriate ♦ ♦ MCMC logit Hi, I have a dataset with the binary outcome Y(0,1) and 4 covariates (X1,X@,X#,X$). I am trying to use MCMClogit to model logistic regression using MCMC. I am getting an error where it doesnt identify the covariates ,although its reading in correctly. The dataset is a sample of actual dataset. Below is my code: > ####################### > > > #retreive data > # considering four covariates > d.df=as.data.frame(read.table("c:/tina/phd/thesis/data/modified_data1.1.txt",header=T,sep=",")) > y=d.df[,ncol(d.df)] > x=d.df[,1:4] > c.df=cbind(y,x) > #x=cbind(1,x) > p <- ncol(c.df) > > # marginal log-prior of beta[] > logpriorfun <- function(beta, mu, gshape, grate) + { + logprior = -p*log(2) + log(gamma(p+gshape)) - log(gamma(gshape)) + + gshape*log(grate) - (p+gshape)* log(grate+sum(abs(beta))) + return(logprior) + } > require(MCMCpack) Loading required package: MCMCpack Loading required package: coda Loading required package: lattice Loading required package: MASS ## ## Markov Chain Monte Carlo Package (MCMCpack) ## Copyright (C) 2003-2007 Andrew D. Martin and Kevin M. Quinn ## ## Support provided by the U.S. National Science Foundation ## (Grants SES-0350646 and SES-0350613) ## [1] TRUE Warning message: package 'MASS' was built under R version 2.4.1 > a0 = 0.5 > b0 = 1 > mu0 = 0 > beta.init=list(c(0, rep(0.1,4)), c(0, rep(-0.1,4)), c(0, rep(0, 4))) > burnin.cycles = 1000 > mcmc.cycles = 25000 > # three chains > post.list <- lapply(beta.init, function(vec) + { + posterior <- MCMClogit(y~x1+x2+x3+x4, data=c.df, burnin=burnin.cycles, mcmc=mcmc.cycles, + thin=5, tune=0.5, beta.start=vec, user.prior.density=logpriorfun, logfun=TRUE, + mu=mu0, gshape=a0, grate=b0) + return(posterior) + }) Error in eval(expr, envir, enclos) : object "x1" not found > Any suggestions will be greatly appreciated. Thanks, Anamika --------------------------------- We won't tell. Get more on shows you hate to love [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Ravi Varadhan Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: MCMC logit As the error message clearly indicates, the function MCMClogit is unable
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like http://r.789695.n4.nabble.com/MCMC-logit-td820350.html you, helping each other. Join them; it only takes a minute: Sign up Error with panel data (plm) Error in crossprod(t(X), beta) up vote 6 down vote favorite I have a df (a pdata.frame object): head(df) : Company Year Kapitalinkomster Bank.o.kassa Obligationer Lån Aktier Placeringar.andra.ftg Fodringar Reala.tillgångar 5-1948 5 1948 4.009780 0.8677505 40.12268 54.80897 1.4630271422 0.049855191 http://stackoverflow.com/questions/13048202/error-with-panel-data-plm-error-in-crossprodtx-beta 0.633959879 1.581139e+00 6-1948 6 1948 3.221688 0.9311173 71.16401 26.39038 0.4678139417 0.000000000 0.437931676 4.931845e-01 12-1948 12 1948 3.136025 0.7628832 46.10452 44.85120 4.1966304368 0.003740003 1.020092197 2.683785e+00 19-1948 19 1948 1.862666 0.1865510 16.82441 31.67412 0.7308074302 46.245334945 3.459693951 6.213455e-01 20-1948 20 1948 3.724516 1.7719721 70.98456 27.18631 0.0004305687 0.056565968 0.000165769 4.305687e-07 21-1948 21 1948 11.288744 1.1572048 64.21109 33.42962 0.2890377378 0.000000000 0.912175552 1.150518e-06 Övriga.tillgångar 5-1948 0.4726258998 6-1948 0.1155685107 12-1948 0.3771504323 19-1948 0.2577362013 20-1948 0.0000000000 21-1948 0.0008697916 I then try to do a random model with plm package (Kapitalinkomster variable is regressed on the remaining variabler): library(plm) random <- plm(formula=Kapitalinkomster~ Bank.o.kassa+Obligationer+Lån+ Aktier+Placeringar.andra.ftg+Fodringar+Reala.tillgångar+Övriga.tillgångar,data=df,index=c("Company","Year"), model="random") I can get the output : random Model Formula: Kapitalinkomster ~ Bank.o.kassa + Obligationer + Obligationer + Lån + Aktier + Placeringar.andra.ftg + Fodringar + Reala.tillgångar + Övriga.tillgångar Coefficients: (Intercept) Bank.o.kassa Obligationer Lån Aktier Placeringar.andra.ftg 0.7204962 0.0441635 0.0297014 0.0618975 0.0023219 0.0142085 Fodringar Reala.tillgångar 0.0341745 -0.0104192 Above I can see the Övriga.tillgångar variable in Model Formula but not in Coefficients.. The problem is also that I cant get the summary when Övriga.tillgångar vari
Sign in Pricing Blog Support Search GitHub This repository Watch 2 Star 2 Fork 0 napaxton/ZeligPanelmodels Code Issues 1 Pull requests 0 Projects 0 Wiki Pulse Graphs New issue Fixed/within setx() objects #2 Open https://github.com/napaxton/ZeligPanelmodels/issues/2 napaxton opened this Issue Apr 15, 2013 · 1 comment Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 1 participant Owner napaxton commented Apr 15, 2013 From Justin Murphy (justin dot murphy at temple dot edu): I'm able to run my panel model in Zelig but the setx command runs into errors no matter how I try it. For instance, attempting a simple error in unconditional prediction: x.out<-setx(z.out.fe) gives: series scode, xyear, xpolity2, xspending.wb..., xdependency.wb, xland.wb are constants and have been removed Warning message: In is.na(id) : is.na() applied to non-(list or vector) of type 'NULL' Owner napaxton commented Apr 15, 2013 From previous conversation with Matt Owen (mowen at iq dot harvard dot edu) On Feb 6, 2013, at 11:59, "Owen, Matthew" wrote: Hi Nathan - Everything's good over. I hope the same for error in tune you. First off, everything I'm about to reference is in my github project: http://github.com/napaxton/ZeligPanelmodels. I'm working in the development ("develop") branch. I've also attached the R CMD check logs. Cool Figuring that this had something to do with the differences in structure between FE and RE objects, I checked those, and indeed, the FE object (as expected) has no intercept term. Is this what's causing the error in the matrix multiplication of beta %*% x ? How can this be fixed? (I.e., does there somehow have to be an intecept vector faked in or something?) Assuming you're working with the design matrix, a simple fix might be to do something like: designMatrix[, "(Intercept)"] <- 0 Etc. So the model matrix for an fe object doesn't have an intercept, so this would make more sense to have the intercept value be NA? I looked at some of the documentation on design/model matrices, and here's what I understand them to be: matrices where each row corresponds to a row in the orig data, and columns correspond to the variable, with cells being the residual on the estimated variable for that particular case. (Let me know if I'm wrong here.) The intercept column is all 1's; is this to say that "yes,