Displaying 20 results from an estimated 7000 matches similar to: "function runif in for loop"
2011 Aug 15
2
MCMC regress, using runif()
Hello,
just to follow up a question from last week. Here what I've done so far (here an example):
library(MCMCpack)
Y=c(15,14,23,18,19,9,19,13)
X1=c(0.2,0.6,0.45,0.27,0.6,0.14,0.1,0.52)
X2a=c(17,22,21,18,19,25,8,19)
X2b=c(22,22,29,34,19,26,17,22)
X2 <- function()runif(length(X2a), X2a, X2b)
model1 <- MCMCregress(Y~X1+X2())
summary(model1)
but I am not sure if my X2-function is
2011 Aug 15
2
plotting segments only and in color
Hello,
I've a question concerning the display of interval data.
A sample dataset where X is an interval between Xa and Xb
which should be displayed:
Y=c(15,14,23,18,19,9,19,13)
Xa=c(17,22,21,18,19,25,8,19)
Xb=c(22,22,29,34,19,26,17,22)
X = (Xa+Xb)/2
It's easily possible to plot the mean of the interval like:
plot(X,Y)
afterwards I can create lines for the interval with:
2011 Jul 28
1
Regression with ranges and displaying them in an XY-Plot
Hello UseRs,
I've got 3 variables, the dependent variable Y as well as a max and a min value of the independent variable (Xa and Xb) where in some cases Xa=Xb (so actually a single value for X).
First I'd like to perform a regression, but my problem is that my X is a range (acutally a censored independent variable Xa-Xb) rather then one single value. I know already some possible
2003 Apr 18
1
MCMCpack gelman.plot and gelman.diag
Hi,
A question. When I run gelman.diag and gelman.plot
with mcmc lists obtained from MCMCregress, the results are following.
> post.R <- MCMCregress(Size~Age+Status, data = data, burnin = 5000, mcmc = 100000,
+ thin = 10, verbose = FALSE, beta.start = NA, sigma2.start = NA,
+ b0 = 0, B0 = 0, nu = 0.001, delta = 0.001)
> post1.R <- MCMCregress(Size~Age+Status, data
2005 Sep 02
1
source package linking problem under linux
I'm having some problems in installing some source packages under linux.
As an example, MCMCpack. An error is raised when linking:
> install.packages("MCMCpack")
[...]
* Installing *source* package 'MCMCpack' ...
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking
2008 Oct 18
1
Fehler in x$terms : $ operator is invalid for atomic vectors
Dear All
I try to use your R package MCMCpack and I have encountered the following problem:
The following code works fine:
library(MCMCpack)
line <- list(X = c(-2,-1,0,1,2), Y = c(1,3,3,3,5))
posterior1 <- MCMCregress(X~Y, data=line)
summary(posterior1)
But as long as I try the following lines
library(MCMCpack)
line <- list(X = c(-2,-1,0,1,2), Y = c(1,3,3,3,5))
2006 Aug 11
2
about MCMC pack again...
Hello, thank you very much for your previous answers about the C++ code.
I am interested in the application of the Gibbs Sampler in the IRT
models, so in the function MCMCirt1d and MCMCirtkd. I've found the C++
source codes, as you suggested, but I cannot find anything about the
Gibbs Sampler. All the files are for the Metropolis algorithm.
Maybe I am not able to read them very well, by the
2012 Feb 09
1
Constraint on one of parameters.
Dear all,
I have a function to optimize for a set of parameters and want to set a
constraint on only one parameter. Here is my function. What I want to do is
estimate the parameters of a bivariate normal distribution where the
correlation has to be between -1 and 1. Would you please advise how to
revise it?
ex=function(s,prob,theta1,theta,xa,xb,xc,xd,t,delta) {
expo1=
2011 Nov 22
5
x, y for point of intersection
Hi everyone,
?
I am trying to get a point of intersection between a
polyline and a straight line ?.. and get the x and y coordinates of this point.
For exemplification consider this:
?
?
set.seed(123)
?
k1 <-rnorm(100, mean=1.77, sd=3.33)
?k1 <- sort(k1)
q1 <- rnorm(100, mean=2.37, sd=0.74)
q1 <- sort(q1, decreasing = TRUE)
plot(k1, q1, xlim <- c((min(k1)-5),
2012 Jul 10
3
fill 0-row data.frame with 1 line of NAs
Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:
> (.xb <- iris[ iris$Species=='zz', ])
[1] Sepal.Length Sepal.Width Petal.Length Petal.Width Species
<0 rows> (or 0-length row.names)
> dim(.xb)
[1] 0 5
> (.xa <-
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists:
xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) )
xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site
, FUN=function(z)yield[z]))
I can convert xa to a dataframe easily with:
as.data.frame(xa)
But if i try the same with xb I get:
as.data.frame(xb)
Error in as.data.frame.default(xb) :
can't coerce array into a data.frame
What
2011 Oct 10
4
correlation matrix
Hello Gurus
I have two correlation matrices 'xa' and 'xb'
set.seed(100)
d=cbind(x=rnorm(20)+1,
x1=rnorm(20)+1,
x2=rnorm(20)+1)
d1=cbind(x=rnorm(20)+2,
x1=rnorm(20)+2,
x2=rnorm(20)+2)
xa=cor(d,use='complete')
xb=cor(d1,use='complete')
I want to combine these two to get a third matrix which should have half
values from 'xa' and half
2012 Jun 21
4
convert 'character' vector containing mixed formats to 'Date'
Dear all
I have a 'character' vector containing mixed formats (thanks Excel!)
and I'd like to translate it into a default "%Y-%m-%d" Date vector.
x <- c("1/3/2005", "13/04/2004", "2/5/2005", "2/5/2005", "7/5/2007",
"22/04/2004", "21/04/2005", "20080430", "13/05/2003",
2004 Mar 28
2
splitting a character vector
Dear R People:
Suppose I have the following;
xa <- c("There are 5 dogs")
I would like to have a new character vector such that
xb[1] is There
xb[2] is are
xb[3] is 5
xb[4] is dogs
Since the original vector has length 1, substring will not work.
Any suggestions would be MOST welcome!
thanks
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
2013 Jul 16
2
Problem following an R bug fix to integrate()
I have been told by the CRAN administrators that the following code generated
an error on 64-bit Fedora Linux (gcc, clang) and on Solaris machines (sparc,
x86), but runs well on all other systems):
> fn <- function(x, y) ifelse(x^2 + y^2 <= 1, 1 - x^2 - y^2, 0)
> tol <- 1.5e-8
> fy <- function(x) integrate(function(y) fn(x, y), 0, 1,
2009 Nov 25
1
group generics
I have classes A and B, where B contains A. In the implementation of
the group generic for B I would like to use the corresponding group
generic for A. Is there a way to do that?
I would also appreciate any comments if what I'm trying to do seems like
the wrong approach.
Here's a stripped down example:
setClass("A",
2017 May 30
2
Pseudo-instruction that overwrites its input register
On Tue, 30 May 2017, Nemanja Ivanovic wrote:
> This is typically accomplished with something like PPC's `RegConstraint` and
> `NoEncode`. You can see examples of it that are very similar to what you're after in
> PPC's load/store with update forms (i.e. load a value and update the base register
> with the effective address - these are used for pre-increment loads/stores).
2013 Apr 16
1
avoid losing data.frame attributes on cbind()
Dear all,
How should I add several variables to a data frame without losing the
attributes of the df? Consider the following:
> require(Hmisc)
> Xa <- iris
> label(Xa, self=T) <- "Some df label"
> str(Xa)
'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9
2017 May 28
2
Pseudo-instruction that overwrites its input register
On Sun, 28 May 2017, David Chisnall wrote:
>> let Constraints = "@earlyclobber $reg" in
>> def LDWRdPtr : Pseudo<(outs DREGS:$reg),
>> (ins PTRREGS:$ptrreg),
>> "ldw\t$reg, $ptrreg",
>> [(set i16:$reg, (load i16:$ptrreg))]>,
>>
2009 Aug 23
2
difficult "for"
Hi,
My english isn't brilliant and my problem is very difficult to describe but
I try ;)
My first question is: May I write loop "for" like this or similar - for (i
in sth : sth[length(sth)], k in sth_else : length(sth_else) ) - I'd like
to have two independent conditions in the same loop "for".
My secound question depend on program below. I'd like to write every