Thanks, it worked without quotation marks.
--
View this message in context:
http://r.789695.n4.nabble.com/ifelse-numeric-tp4650390p4650482.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat
Hi,
I have a data frame and I need to add another column.
I am using: data[,4] <- ifelse(data[,3]<1,data[,1]/(1-data[,3]),"NA")
This is returning values but are in quotation marks. The error I am getting
is "non-numeric argument to binary operator"
I need column four in data to be numeric. Trie
I think this is what you want.
p <- c(1/10, 2/5, 2/5, 2/5, 2/5, 1/10, 1/10, 1/10, 1/10, 1/10)
psidp <- function(x){
if (x>0&&x<=10)
{
return(sum(p[1:x]))
}
else{
return("Input integer between 1 and 10")
}}
--
View this message in context:
http://r.789695.n4.nabble.com/Help-plz-to-fix-it-tp4647
Hi,
I think I solved it myself by writing loops.
What I meant is: are there in-built functions in R that calculate the
following:
a1(b2+...+b190) + a2(b1+b3+...+b190) + ...
I managed to solve it, quite similar to what you just emailed.
Thanks anyway!
--
View this message in context:
http:
I am aware of the most basic stuff, especially vectorization and
subscripting.
I only gave a simple example with length 4. I need to do that for vectors of
length 190.
Are there any in-built commands?
Or should I write the loops myself?
Thank you.
--
View this message in context:
http://r.7
I would like to code the following in R: a1(b1+b2+b3) + a2(b1+b3+b4) +
a3(b1+b2+b4) + a4(b1+b2+b3)
or in summation notation: sum_{i=1, j\neq i}^{4} a_i * b_i
I realise this is the same as: sum_{i=1, j=1}^{4} a_i * b_i - sum_{i=j} a_i
* b_i
would appreciate some help.
Thank you.
--
View this
I am trying to use the optim command to get the MLEs for a number of
parameters based on some data. Is it possible to write a program that
maximizes the likelihood and stores the parameters (many times)? I need to
do this a lot of times, each time the data will be updated with more entries
(rows).
I understand that the likelihood function is a product and hence the log
likelihood function is a sum. However I can't figure out what the problem
is.
Here's the likelihood function:
[(alpha1*beta2*gamma)^v1 exp^(-alpha1*beta2*gamma)]/v1! * [(alpha2*beta1)^v2
exp^(-alpha2*beta1)]/v2!
Isn't the l
I am trying to run this code and obtain the MLEs for my parameters. However I
am getting this error at the end.
Error in optim(c(1.4, 1.1, 0.8, 0.92, 0.4), poisson.lik, v = v) :
objective function in *optim evaluates to length 100 not 1*
Code:
poisson.lik <- function(theta,v){
v=matrix(c(1,3,2
9 matches
Mail list logo