Displaying 20 results from an estimated 300000 matches similar to: "problem with rinvgamma ?"
2007 Jan 09
4
A question about R environment
Hi all,
I created environment "mytoolbox" by : mytoolbox <- new.env(parent=baseenv())
Is there anyway I put it in the search path ?
If you need some background :
In a project, I often write some small functions, and load them into my workspace directly, so when I list the objects
with ls(), it looks pretty messy. So I am wondering if it is possible to creat an
2006 Sep 27
2
How to pass expression as an argument
Hi,
I am writing a function and need to pass a function expression as an argument, for instance,
myfun <- function( express) {
x<- c(1,2,3)
y<-express
}
if I call the above function by myfun( x*2 ), I get 2 as the result, instead of 2,4,6 , could someone help me to
fix this problem ?
Furthermore, is that
2005 Jun 28
2
How to import data as numeric array?
Did some search but couldn't find useful result.
I am trying to read a n*m dimension data with read.table, what i need is a numeric array,
is there any efficient way to allow me get this array directly instead of a list?
I tried to use as.array() to change the mode, but seems it doesn't work and i got this error message:
"Error in "dimnames<-.data.frame"(`*tmp*`,
2007 Feb 02
2
A question about dput
Hi,
I am trying to output a R data set for use in WinBugs, I used
dput(list(x=rnorm(100),N=100),file="bug.dat")
But I can't get the intended format: list(x=c(.......),N=100), instead, I got
something like this (copied the first two lines):
[00000000]???73?74?72?75??63?74?75?72??65?28?6C?69??73?74?28?78???? structure(list(x
2007 Jan 14
1
Questions about paste and assign
Hi,
I would like to assign a value to a member b of the list a in position 3, by calling:
assign( target, 2.34, 3)
My question is what the "target" should be. I tried target <- paste("a", $, "b") and something else,
but haven't got the right answer yet.
BTW, if I attached a list named
2007 Apr 01
1
Keep R packages in the R installation
Hi,
I just got a quick question here, when I install a new version of R , is there an easy to keep the installed R packages ?
Thanks a lot for any help.
tong
2007 Apr 02
2
Compiling C codes in Windows
Hi All,
I have been struggling to figure out how to compile c codes for R use. I am using Win XP + Cygwin + R binaries.
After I followed all the instructions in " Building R for Windows" from Murdoch's website, I tried to Run something like :
R CMD SHLIB C:\R\test.c , but still didn't get any output.
My first question is, does this mean I already did
2007 Apr 02
2
Compiling C codes in Windows
Hi All,
I have been struggling to figure out how to compile c codes for R use. I am using Win XP + Cygwin + R binaries.
After I followed all the instructions in " Building R for Windows" from Murdoch's website, I tried to Run something like :
R CMD SHLIB C:\R\test.c , but still didn't get any output.
My first question is, does this mean I already did
2007 Dec 27
1
Efficiency of for-loop in R
Hi,
I just realized that in Matlab, as long as memory is pre-allocated, doing for-loop doesn't cost more time than doing things in vector form.
But it seems in R, it still cost a lot to do for-loop. Is there any improvement in R that I missed. Thanks a lot.
Merry Xmas Everyone !
2007 May 26
1
Why ?rmvnorm not working
Hi,
My R version is 2.4.1 and I installed the the packages MASS and run
command library("MASS"),
however when I type ?rmvnorm, no help topic found, it worked before.
I tried to ype ?rinvgamma from "MCMCpack" which works great.
Anybody have idea? I also reinstalled MASS package, but when I try to type
rmvnorm(), no functions found.
Pat
2007 Jan 04
1
need help with debug package
Hi all,
I met a problem while using the debug package, I have the following program:
mainfun<- function(){
beta<-1
result<-subfun(beta+x)
}
subfun<-function(expr){
y <- eval(expr, envir=list(x=c(1,2)),enclos = parent.frame())
return(y)
}
I have no problem using this program without calling the debug
2006 Mar 17
1
How to change the label in plot.ts ?
Hi you guys:
I have been wondering if there is any way to change the labeling in plot.ts( ), for example , if I plot two sequences,
i always got y labels as "series1", "series2", I tried to use ylab=c((expression(mu_1)),(expression(mu_2))), but it
doesn't work.
thanks in advance for any help
best.
2006 Oct 28
1
A quesiton on data manipulation
Hi,
I have a data set (data frame) describing some features of the students in a high school in the following format:
Stu ID Year feature 1 feature 2 .............
1001 1990
1001 1991
1001 1992
1002 1990
1002 1991
1002 1992
Some features of a few of these students are missing, I would like to
2009 Oct 08
3
foreach loop - rejection method
Hi Everybody,
Thanks in advance for your help.
This is my first time using the foreach statement and I cant get it to work
properly so here is what i have
test<-function(){
repeat {
cand2[l-1]<-rinvgamma(1,phi,lambda[l-1])
q2<-dinvgamma(cand2[l-1],phi,lambda[l-1])
p2<-cand2[l-1]^-1.5*exp(-y[l]^2/(2*cand2[l-1]))*exp(-((log(cand2[l-1])-mu_t_cand[l-1])^2)/2*sigmasq)
2007 Feb 13
0
Really need help here
Hi there,
I had a serious problem here . Consider the following Bayesian model(discretized variance gamma):
#Likelihood
J[i]<-lambda*G[i]+sigma*sqrt(G[i])*rnorm(0,1)
G[i]<-rgamma(1/nu,1/nu)
#Prior:
nu<-rinvgamma(m,M)
# Parameters
lambda=-.04 ; sigam=.38; nu=6.48; m=10,M=10 ; T=5000 (length of data)
An author claimed that he got posterior distribution
2012 Oct 04
2
Help with R Fitting an inverse Gamma
Dear all,
I am new in R and would like to ask for someone's help in understanding
where I go wrong with the following code:
rm(list=ls())
# Required packages
library(MCMCpack)
# Simulated data
set.seed(1)
data = rinvgamma(n=250, shape = 5, scale = 2) + 2
hist(data)
# log-likelihood
ll = function(par){
if(par[1]>0 & par[2]>0 & par[3]<min(data)) return(
2007 Apr 23
2
Problem with dgamma ?
Hi All,
Here 's what I got using dgamma function :
> nu<-.2
> nu*log(nu)-log(gamma(nu))+(nu-1)*log(1)-nu*(1)
[1] -2.045951
> dgamma(1,nu,nu,1)
[1] 0.0801333
> dgamma(1,nu,nu,0)
[1] NaN
Warning message:
NaNs produced in: dgamma(x, shape, scale, log)
Could anyone tell me what is wrong here ?
I am using R-2.4.1 on windows XP.
Thanks a lot.
2015 Mar 18
1
Folders with ~ (tilde) slow to save
I tried to close everything I had open and filter as best as I could..
but left random lines in just in case it helps.
172.16.5.230 is my local machine and *.33.235 is the server.
This is a slow save..
13:48:39.852340 (60) 001F5B35DB28 Broadcast UDP - Other
Ports 172.16.5.93 172.16.5.255 00:04:53.922946 293.922946
13:48:39.852605 (60) 001F5B35DB28 USC-IANA
2007 Apr 03
3
Strange number produced by dnorm
Hi All,
I just started to learn compiling C codes for R usage, and got a problem when I was playing with my 'hello world' code.
#include <R.h>
#include <Rdefines.h>
#include <Rmath.h>
SEXP test( ) {
double x;
x=dnorm(1.0,0.0,1.0,1);
printf(" x value is: %d \n",x);
return(R_NilValue);
}
I got the result : x value is: -466460838
Could
2002 Sep 18
2
More on list to data frame (was: Re: List to Data Frame
Hi,
Now suppose I have just one list called FOO, which has 25 objects, e.g.:
[[1]]
1 2 3 4 5
[[2]]
6 7 8 9 10
.
.
.
And I want to do something like:
FRED <- data.frame(cbind(unlist(FOO[[1]]),
unlist(FOO[[2]]),
# ... for all 25 subsets
))
Is it possible to do this, without doing unlist(FOO[[i]]) 25