Displaying 20 results from an estimated 20000 matches similar to: "read.dta function in foreign package"
2009 May 04
1
Nelson-Aalen estimator of cumulative hazard
Hi,
I am computing the Nelson-Aalen (NA) estimate of baseline cumulative hazard in two different ways using the "survival" package. I am expecting that they should be identical. However, they are not. Their difference is a monotonically increasing with time. This difference is probably not large to make any impact in the application, but is annoyingly non-trivial for me to just
2008 Oct 29
1
Regression versus functional/structural relationship?
Hi,
I am dealing with the following problem. There are two biochemical assays,
say A and B, available for analyzing blood samples. Half the samples have
been analyzed with A. Now, for some insurmountable logistic reasons, we
have to use B to analyze the remaining samples. However, we can do a
comparative study on a small number of samples where we can obtain
concentrations using both A and
2011 Aug 31
1
Gradients in optimx
Hi Reuben,
I am puzzled to note that the gradient check in "optimx" does not work for you. Can you send me a reproducible example so that I can figure this out?
John - I think the best solution for now is to issue a "warning" rather than an error message, when the numerical gradient is not sufficiently close to the user-specified gradient.
Best,
Ravi.
2011 Feb 18
2
How to flag those iterations which yield a warning?
Hi,
I am running a simulation study with the survival::coxph. Some of the simulations result in problematic fits due to flat partial likelihood. So, you get the warning message:
Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights, ... :
Loglik converged before variable 2 ; beta may be infinite.
How can I keep track of the simulations which yield any kind of
2013 Jan 16
1
Read.dta and Write.dta Binary Data Error
Thanks in advance.
I pass data sets between R and Stata and think dta files would be the best
files for this. To do this I can use package foreign or package memisc. I
mostly use foreign, although have used memisc and this problem mostly didn't
happen, but created errors at other times.
I have a csv data set (and created a test case) with with at least one
column completely missing. This
2008 Mar 18
2
read.dta for files from stata 9.0
Dear R-helpers,
if I want to read a .dta-file generated by stata 9.0 with read.dta
(foreign), I get the message
"not a stata version 5-8 .dta-file". I'm using R-2.6.2 and the latest
version of the foreign package. Has someone any hint?
With many thanks,
Albrecht
2008 Jan 10
1
write.dta (foreign package)
Hi,
I'd like to request that the 'write.dta' command also save the
"var.labels" attributes of the data frame.
'read.dta' can read them, but 'write.dta' doesn't write them back.
Thanks....
Edward McNeil
--
Epidemiology Unit
Faculty of Medicine
Prince of Songkla University
Hat Yai
THAILAND
(\_ _/)
(='.'=)
('')_('')
--
This
2008 Apr 09
4
Skipping specified rows in scan or read.table
Hi,
I have a data file, certain lines of which are character fields. I would
like to skip these rows, and read the data file as a numeric data frame. I
know that I can skip lines at the beginning with read.table and scan, but is
there a way to skip a specified sequence of lines (e.g., 1, 2, 10, 11, 19,
20, 28, 29, etc.) ?
If I read the entire data file, and then delete the character
2006 Oct 27
2
Multivariate regression
Hi,
Suppose I have a multivariate response Y (n x k) obtained at a set of
predictors X (n x p). I would like to perform a linear regression taking
into consideration the covariance structure of Y within each unit - this
would be represented by a specified matrix V (k x k), assumed to be the same
across units. How do I use "lm" to do this?
One approach that I was thinking of
2013 Jan 30
1
starting values in glm(..., family = binomial(link =log))
Try this:
Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), family=quasibinomial(link = log))
Ravi
Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvaradhan@jhmi.edu<mailto:rvaradhan@jhmi.edu>
410-502-2619
[[alternative HTML version deleted]]
2002 Nov 25
3
How top print intermediate values from inside a function?
Hi:
In R, how do I display some intermediate results calculated in a "for"
loop within a function? For example, in the attached code, how do I
get it to print the intermediate variable "mh.new" for each simulation,
when I call the function "MHsim.ind"?
thanks for any help,
Ravi.
####################################################################
MHsim.ind
2009 Oct 15
4
Generating a stochastic matrix with a specified second dominant eigenvalue
Hi,
Given a positive integer N, and a real number \lambda such that 0 < \lambda
< 1, I would like to generate an N by N stochastic matrix (a matrix with
all the rows summing to 1), such that it has the second largest eigenvalue
equal to \lambda (Note: the dominant eigenvalue of a stochastic matrix is
1).
I don't care what the other eigenvalues are. The second eigenvalue is
2006 Nov 29
2
How to solve differential equations with a delay (time lag)?
Hi,
I would like to solve a system of coupled ordinary differential equations,
where there is a delay (time lag) term. I would like to use the "lsoda"
function "odesolve" package. However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.
Here is an example of the kind of problem that I am trying to solve:
> library(odesolve)
2010 Sep 30
3
how to avoid NaN in optim()
hi ,
lik <- function(nO, nA, nB, nAB){
loglik <- function(par)
{
p=par[1]
q=par[2]
r <- 1 - p - q
if (c(p,q,r) > rep(0,3) && c(p,q,r) < rep(1,3) )
{
-(2 * nO * log (r) + nA * log (p^2 + 2 * p * r)
+ nB * log (q^2 + 2 * q * r)
+ nAB * (log(2) +log(p) +log(q)))
}
else
NA
}
loglik
}
2006 Sep 29
2
X-axis labels in histograms drawn by the "truehist" function
Hi,
I have a simple problem that I would appreciate getting some tips. I am
using the "truehist" function within an "apply" call to plot multiple
histograms. I can't figure out how to get truehist to use the column names
of the matrix as the labels for the x-axis of the histograms.
Here is a simple example:
X <- matrix(runif(4000),ncol=4)
colnames(X)
2009 Feb 19
2
Source code for nlm()
Hi,
Where can I find the source code for nlm()? I dowloaded the R2.8.1.tar.gz
file and looked at all the .c and .f files, but couldn't find either nlm.c
or nlm.f
There is an nlm.r file, but that is not useful.
Thanks for any help,
Ravi.
----------------------------------------------------------------------------
-------
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging
2006 Nov 14
2
Matrix-vector multiplication without loops
Hi,
I am trying to do the following computation:
p <- rep(0, n)
coef <- runif(K+1)
U <- matrix(runif(n*(2*K+1)), n, 2*K+1)
for (i in 0:K){
for (j in 0:K){
p <- p + coef[i+1]* coef[j+1] * U[,i+j+1]
} }
I would appreciate any suggestions on how to perform this computation
efficiently without the "for" loops?
Thank
2004 Jul 03
4
counting the occurrences of vectors
Hi:
I have two matrices, A and B, where A is n x k, and B is m x k, where n >> m >> k. Is there a computationally fast way to count the number of times each row (a k-vector) of B occurs in A? Thanks for any suggestions.
Best,
Ravi.
[[alternative HTML version deleted]]
2007 Feb 01
3
Need help writing a faster code
Hi,
I apologize for this repeat posting, which I first posted yesterday. I would
appreciate any hints on solving this problem:
I have two matrices A (m x 2) and B (n x 2), where m and n are large
integers (on the order of 10^4). I am looking for an efficient way to
create another matrix, W (m x n), which can be defined as follows:
for (i in 1:m){
for (j in 1:n) {
W[i,j] <-
2008 Mar 13
3
Use of ellipses ... in argument list of optim(), integrate(), etc.
Hi,
I have noticed that there is a change in the use of ellipses or . in R
versions 2.6.1 and later. In versions 2.5.1 and earlier, the . were always
at the end of the argument list, but in 2.6.1 they are placed after the main
arguments and before method control arguments. This results in the user
having to specify the exact (complete) names of the control arguments, i.e.
partial matching is