Displaying 20 results from an estimated 8000 matches similar to: "Function to approximate complex integral"
2006 Apr 19
4
Basic vector operations was: Function to approximate complex integral
Dear List
I apologize for the multiple postings. After being in the weeds on this
problem for a while I think my original post may have been a little
cryptic. I think I can be clearer. Essentially, I need the following
a <- c(2,3)
b <- c(4,5,6)
(2*4) + (2*5) + (2*6) + (3*4) + (3*5) +(3*6)
But I do not know of a built in function that would do this. Any
suggestions?
-----Original
2006 Aug 24
1
Optim question
This is a very basic question, but I am a bit confused with optim. I
want to get the MLEs using optim which could replace the newton-raphson
code I have below which also gives the MLEs. The function takes as input
a vector x denoting whether a respondent answered an item correctly
(x=1) or not (x=0). It also takes as input a vector b_vector, and these
are parameters of test items (Rasch estimates
2010 Jun 02
1
Use apply only on non-missing values
I have a function that I am currently using very inefficiently. The following are needed to illustrate the problem:
set.seed(12345)
dat <- matrix(sample(c(0,1), 110, replace = TRUE), nrow = 11, ncol=10)
mis <- sample(1:110, 5)
dat[mis] <- NA
theta <- rnorm(11)
b_vector <- runif(10, -4,4)
empty <- which(is.na(t(dat)))
So, I have a matrix (dat) with some values within the matrix
2009 Nov 29
1
optim or nlminb for minimization, which to believe?
I have constructed the function mml2 (below) based on the likelihood function described in the minimal latex I have pasted below for anyone who wants to look at it. This function finds parameter estimates for a basic Rasch (IRT) model. Using the function without the gradient, using either nlminb or optim returns the correct parameter estimates and, in the case of optim, the correct standard
2006 Jul 20
2
Timing benefits of mapply() vs. for loop was: Wrap a loop inside a function
List:
Thank you for the replies to my post yesterday. Gabor and Phil also gave
useful replies on how to improve the function by relying on mapply
rather than the explicit for loop. In general, I try and use the family
of apply functions rather than the looping constructs such as for, while
etc as a matter of practice.
However, it seems the mapply function in this case is slower (in terms
of CPU
2007 Dec 12
0
IRT Likelihood problem
I have the following item response theory (IRT) likelihood that I want
to maximize w.r.t. to theta (student ability).
L(\theta) = \prod(p(x))
Where p(x) is the 3-parameter logistic model when items are scored
dichotomously (x_{ij} = 0 or 1) and p(x) is Muraki's generalized partial
credit model when items are scored polytomously (x_{ij} = 0 \ldots J).
Now, I wrote the following two functions
2007 Jun 22
2
Data consistency checks in functions
Dear friends,
I'm writing a function with three arguments
myfun <- function(theta, X, values)
{
....
....
}
in this function, I'm trying to write consistency checks. In order to compute the statistic of interest I only need theta and values. The idea of having X in there is that, if values is not provided by the user, then values is computed from X.
my problem is I'm trying to
2011 May 04
1
hurdle, simulated power
Hi all--
We are planning an intervention study for adolescent alcohol use, and I
am planning to use simulations based on a hurdle model (using the
hurdle() function in package pscl) for sample size estimation.
The simulation code and power code are below -- note that at the moment
the "power" code is just returning the coefficients, as something isn't
working quite right.
The
2006 Aug 30
4
Create a vector from another vector
Dear list
Suppose I have the following vector:
x <- c(3,4,2,5,6)
Obviously, this sums to 20. Now, I want to have a second vector, call it
x2, that sums to x where 5 <= x <= 20, but there are constraints.
1) The new vector must be same length as x
2) No element of the new vector can be 0
3) Element x2[i] of the new vector cannot be larger than element x[i] of
the original vector
4)
2006 May 05
0
Spline integration & Gaussian quadrature (was: gauss.quad.prob)
Spencer
Thanks for your thoughts on this. I did a bit of work and did end up
with a method (more a trick), but it did work. I am certain there are
better ways to do this, but here is how I resolved the issue.
The integral I need to evaluate is
\begin{equation}
\frac{\int_c^{\infty} p(x|\theta)f(\theta)d\theta}
{\int_{-\infty}^{\infty} p(x|\theta)f(\theta)d\theta}
\end{equation}
Where
2007 May 08
0
MiscPsycho Package 1.0
I have just submitted MiscPsycho to CRAN. MiscPsycho contains functions
for miscellaneous psychometrics that may be useful for applied
psychometricians. MML estimation already exists in the ltm package.
Hence, a jml option is provided for users who prefer this method. The
jml function gives back rasch difficulties and the same Infit and Outfit
statistics as Winsteps.
Also, jml is known to return
2007 May 08
0
MiscPsycho Package 1.0
I have just submitted MiscPsycho to CRAN. MiscPsycho contains functions
for miscellaneous psychometrics that may be useful for applied
psychometricians. MML estimation already exists in the ltm package.
Hence, a jml option is provided for users who prefer this method. The
jml function gives back rasch difficulties and the same Infit and Outfit
statistics as Winsteps.
Also, jml is known to return
2012 Jan 26
1
eRm package - Rasch simulation
When I try to create a Rasch simulation of data using the sim.rasch
function, I get more items than I intend
#My code
library(eRm)
#Number of items
k <- 20
#Number of participants
n <- 100
#Create Rasch Data
#sim.rasch(persons, items, seed = NULL, cutpoint = "randomized")
r.simulation <- sim.rasch(n,k)
I end up with 20 participants and 100 items, but the instructions say
2012 Jan 26
1
eRm - Rasch modeling - First item missing from estimation
I'm trying to kick off some of the rust and learn some of the R packages
for Rasch modeling. When I tried using the eRm package, I get item
difficulty estimates for all my items accept the first (in terms of order)
item.
#Begin code
library(eRm)
r.simulation <- sim.rasch(20,100)
r.data <- r.simulation$items
#eRm results
erm.rasch <- RM(r.data)
names(erm.rasch)
erm.items <-
2010 Mar 20
0
Getting a complete vector of Theta estimates from Package LTM
I am using package LTM to estimate a Rasch model:
irtestimates <- rasch(binRasch)
I want to get a single vector containing theta estimates for all the
rows (individuals) in my data matrix (hopefully in the same order as
my data matrix) such that the length of the theta vector = the number
of rows (participants) in my data matrix. I am using:
theta.est <-
2008 Oct 19
1
multivariate integral with ADAPT when the parameter is close to boundary
Dear All,
There is one problem I encountered when I used ADAPT to compute some
2-D integral w.r.t beta density.
For example, when I try to run the following comments:
fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))}
int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4)
It seems it will take very long time to run. Acturally, I
2008 Sep 18
2
Ability estimates for partial credit model
Dear all,
I'm working on ability estimates using Rasch model. Using the "ltm"
package, the procedure is quite simple:
## Factor Scores for the Rasch model
fit <- rasch(LSAT)
factor.scores(fit)
What about Partial Credit Model (PCM)? For PCM I use PCM function from
eRm package. Is there any similar function like factor.scores to
estimate ability scores using PCM model?
Best,
2002 Jul 12
2
'R' library for Rasch modelling?
I'm new to 'R', so forgive me if I've used the wrong term.
I'd like to model some Likert-style items using Rasch methods.
I've been unable to find mention of these for 'R'. Would someone happen to
know of any?
Thanks in any case.
Bill
------------
"It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery
2003 Feb 28
2
optim
Dear all,
I have a function MYFUN which depends on 3 positive parameters TETA[1],
TETA[2], and TETA[3]; x belongs to [0,1].
I integrate the function over [0,0.1], [0.1,0.2] and
[0.2,0.3] and want to choose the three parameters so that
these three integrals are as close to, resp., 2300, 4600 and 5800 as
possible. As I have three equations with three unknowns, I expect the
exact fit, i.e., the SS
2010 Sep 03
3
S4 Method Signatures
Hello,
If the signature of a method defines which generic it implements then I'm confused about why this minimal example I invented won't work :
setGeneric("myFun", function(rs, ...){standardGeneric("myFun")})
setGeneric("myFun", function(cs, ...){standardGeneric("myFun")})
setMethod("myFun", "numeric", function(rs, colour =