gmane.comp.lang.r.general
http://blog.gmane.org/gmane.comp.lang.r.general
hourly11901-01-01T00:00+00:00Gmanehttp://gmane.org/img/gmane-25t.png
http://gmane.org
running the aggregate claims distribution using the package"actuar"
http://comments.gmane.org/gmane.comp.lang.r.general/314478
<pre># i run the following after fitting claims data into the negative binomial
as the frequency distribution and the lognormal for the severity
distribution using the package "fitdistrplus".
require(actuar)
fx<- discretize(plnorm(x,11.69,0.79331),method="unbiased",step=500,from=0,
to=qlnorm(1-1E-6,11.69,0.79331),lev=levlnorm(x,11.69,0.79331))
pb<- 2.6/18.6
pn<- dnbinom(0:qnbinom(1-1E-6,size=2.6,prob=pb),size=2.6,prob=pb)
Fs<-
aggregateDist("convolution",model.sev=fx,model.freq=pn,x.scale=1,tol=1E-6)
# The Fs function stalls and does not produce and output. Can anyoen advise
why this is the case?
# On the other hand does the convolution method require iterations.
# In case the function Fs run successfully how are the parameters of the Fs
distribution extracted. How would the same parameters be related to an
existing portfolio of outstanding claims.
[[alternative HTML version deleted]]
</pre>Charles Thuo2014-10-22T09:02:01[Sweave] doesn't accept unicode?
http://comments.gmane.org/gmane.comp.lang.r.general/314474
<pre>Of course I manage and write my tex-files in unicode (utf-8) (running
XeTeX). That is why my R-output need to be in unicode, too.
But Sweave doesn't accept unicode files.
[R]
Fehler: ‘analy.Snw’ is not ASCII and does not declare an encoding
[/R]
[analy.Snw]
<<>>=
x <- ü
table(x)
< at >
[/analy.Snw]
How should I "declare an encoding". I can not find an option for the
<<>>.
I don't have to declare any of my tex-files explicite because XeTeX use
the files like they come. It knows for itself the encoding.
______________________________________________
R-help< at >r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
</pre>moonkid< at >posteo.org2014-10-22T00:45:33add text to the first line of an output file
http://comments.gmane.org/gmane.comp.lang.r.general/314473
<pre>Hi guys;
I want to write some text at the first line of an output file. The output
file will be used for other software. In particular, the following text
"ampl.tab 2 1" needs to be added to the first line of an df output file.
As a hypothetic example, the output in text file should be like:
ampl.tab 2 1
A B
2 3
4 6
2 0
Thanks for help.
Yihsu
[[alternative HTML version deleted]]
</pre>YIHSU CHEN2014-10-22T00:32:25Socket question about isIncomplete and isOpen
http://comments.gmane.org/gmane.comp.lang.r.general/314472
<pre>
I am trying to repeat socket example in ?socketConnection
Server process :
con1 <- socketConnection(port = 6011, server = TRUE)
while(TRUE) { writeLines("aaaaa",con1 ); Sys.sleep(1) }
Client process
con2 <- socketConnection(Sys.info()["nodename"], port = 6011)
readLines(con2, n = 1 )
while(isIncomplete(con2))
{
msg <- readLines(con2, n = 1 )
if(!(is.character(msg) && length(msg) == 0)) { cat("msg = "); print(msg) }
}
I have two problems
1- client side isIncomplete(con2) is always return FALSE and while loop ends
2- client while loop works if I use isOpen(con2) but if server dies client loop doesn't exit ?
</pre>ce2014-10-22T02:02:57R-code for carrying out step-wise panel regression
http://comments.gmane.org/gmane.comp.lang.r.general/314470
<pre>Dear all
For one of my empirical research investigation, I tried to carry out step-wise panel regression analysis by making adaptation in the use of plm package (since stepAIC command does not work with plm). Say, I tried to regress an explained variable (DEP) on 3 explanatory variables (EX1, EX2, EX3) using a panel data set (dat). Of course, the required set of instructions would be:require(plm)reg <- plm(DEP ~ EX1 + EX2 + EX3, data = dat, method = "within") ... (A)But, what I wish to do (for the purpose of carrying out the analysis iteratively) is as follows:dep <- "DEP"exp <- c("EX1", "EX2", "EX3")and then use somehow these dep and exp to get a statement compatible with (A). I tried the following
frm <- as.formula(paste(dep, "~", exp))reg <- plm(frm, data = dat, method = "within)But it did not work properly. I could get the output only in respect of DEP ~ EX1, whereas I need the same in respect of DEP ~ EX1 + EX2 + EX3.Kindly help. Or, you may pl. suggest some alternative via media</pre>Amarjit Singh2014-10-21T19:35:24MMSB
http://comments.gmane.org/gmane.comp.lang.r.general/314468
<pre>Hi,
I am trying to fit a mixed-membership stochastic blockmodel using mmsb.collapsed.gibbs.sampler. I get an error message: "Error in rep(list(matrix(integer(0), nrow = 2, ncol = 0)), dim(network)[1]) : invalid 'times' argument". Could you explain what is the problem exactly?
I am working on the famous Zachary Karate Club data and have submitted the following code, where ZKCnet was created as an undirected network:
mmsb.collapsed.gibbs.sampler(network=ZKCnet,K=2,num.iterations=50, alpha=1/2,beta.prior=list(matrix(1,2,2),matrix(1,2,2)))
Thank you very much for your help,
Best regards,
St</pre>Stephanie.Clerc< at >sanofi.com2014-10-21T12:24:36"source" command inside R package scripts
http://comments.gmane.org/gmane.comp.lang.r.general/314459
<pre>I have built a new package. I would like to put an R script (let us call it
"script.R) into a subdirectory of the /pkg/R/ directory, called /pkg/R/sub/
and I would like that such code is run when the package is installed.
My way of doing so was to put an R script into /pkg/R/ with source command
like
source("./R/sub/script.R")
that does not give me any error, but I know that the script (which
actuallly defines a few functions is not run. What is wrong? What can I do
better?
Thanks, Enrico
</pre>Enrico Bibbona2014-10-21T11:24:42undesirable output for lm( )
http://comments.gmane.org/gmane.comp.lang.r.general/314457
<pre>Hi,
I have written this code and it is working fine
Example 1:
*****************************************************************************************
Example 2:
I'm getting an undesirable output for this calculation.
Plz help in correcting the mistakes to get clear output.
Regards,
Swapnil Khobragade
e-mail ID: swapnil.khobragade< at >lntinfotech.com<mailto:swapnil.khobragade< at >lntinfotech.com>
Tel: < at >< at >< at >< at >< at >< at >< at >(Direct) | +91 9503043368 (M)
________________________________
The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and using or disseminating the information, and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail"
[[alternative HTML version deleted]]
</pre>Swapnil Khobragade2014-10-21T10:33:29Dealing with NAs in lm or gmm
http://comments.gmane.org/gmane.comp.lang.r.general/314453
<pre>Hi,
My question is about NAs in the function "gmm", but I believe that the
same issues occur in the case of "lm".
I try to estimate a model by "gmm" function (GMM, generalized method of
moments). Each of the variables has 94 rows, but the resulting fitted
model has only 89 rows. Then the function removes the rows with NAs. I
want to add a 94*1 vector, ONI, to the resulting fitted values; I want to
find the fitted value with NAs kept. How can I do it? na.action?
Code:
> gmm8<-gmm(y~RDR1+xx, xiv)
Warning message:
In getDat(object$g, object$x) :
There are missing values. Associated observations have been removed
Error in NextMethod(.Generic) :
dims [product 89] do not match the length of object [94]
In addition: Warning message:
In `+.default`(fitted(gmm8), 0.85 * ONI) :
longer object length is not a multiple of shorter object length
Help on na.action:
na.action
a function which indicates what should happen when the data contain NAs.
The default is set by the na.action setting of optio</pre>jpm miao2014-10-21T08:28:38glmer with multiple random slopes
http://comments.gmane.org/gmane.comp.lang.r.general/314441
<pre>Hi all,
I'm modeling the probability that a subject attacks or rejects a prey
item based on its proportion of yellow coloration and size. There are
two populations of prey, one defended and the other undefended, so
subjects should reject one type and accept others. Each subject has a
unique rejection threshold that is a line on a contour plot with
coloration and size on the x and y axes. I want to estimate the error
around that line's slope, and believe that I need to estimate two random
slopes per subject to do so, one in the color dimension and the other in
the size dimension. The code that I think I should use to do this is:
glmer(attack ~ prop.color + size + (prop.color + size|subject, family =
binomial), but I cannot find a reference or example for fitting random
slopes in different continuous dimensions. I would appreciate any
pointers in the right direction.
Thanks,
David
In case I've given a poor description of the problem, below is code to
visualize the rejection threshold, using an </pre>David Kikuchi2014-10-20T17:48:05How to clear R memory in a for loop
http://comments.gmane.org/gmane.comp.lang.r.general/314428
<pre>Dear Rers,
I am trying to run a for-loop in R.
During each iteration I read in an mp3 file and do some basic processing.
If I do what I need to do for each file one by one - it works fine.
But once I start running a loop, it soon runs out of memory and says: can't
allocate a vector of size...
In each iteration of my loop I always overwrite the previously created
object and do gc().
Any hints on how to fight this?
Thanks a lot!
[[alternative HTML version deleted]]
</pre>Dimitri Liakhovitski2014-10-20T15:30:21making a plot
http://comments.gmane.org/gmane.comp.lang.r.general/314426
<pre>Dear all,
I am struggling to make a plot for my survival analysis
class.
This is my script
labels<-c('1','2','3','4','5','6')
ano<-c(2001,2002,2003,2004,2006,2008)
ranges<-c(6,3,4,5,4,2)
dotchart(ano, labels=labels, xlab='ano',
ylab='Pacientes',pch=20,xlim=c(min(ano), max(ano+ranges)))
segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4)
I need to put an asterix (failure) by the end of the three first lines and
a small circle (censoring)
by the end of the last three.
Someone can help me?
Thanks,
Enrico.
[[alternative HTML version deleted]]
</pre>Enrico Colosimo2014-10-20T14:46:28how to predict scores after varimax rotation (using prcomp()and varimax())?
http://comments.gmane.org/gmane.comp.lang.r.general/314425
<pre>Hello.
I ran a PCA analysis on a dataset with 5 variables and retained two
components. I rotated them and now I want to predict the scores in a new
data set for which the original variables are available.
I normally use the predict.prcomp() function to predict using a prcomp
object. For example..
PC1=predict(data.pca, new.data)[,1]
...will predict the first component in the new dataset.
But how to do it with the rotated components/loadings, since after
varimax() we don't have a prcomp object anymore?
Thanks in advance!
David
[[alternative HTML version deleted]]
</pre>David Villegas Ríos2014-10-20T13:41:30strange loadings matrix after varimax rotation: PCA with prcompin R
http://comments.gmane.org/gmane.comp.lang.r.general/314424
<pre>Hello.
I ran a PCA analysis on a dataset with 5 variables and retained two
components. I rotated them and now I want to predict the scores in a new
data set for which the original variables are available.
I normally use the predict.prcomp() function to predict using a prcomp
object. For example..
PC1=predict(data.pca, new.data)[,1]
...will predict the first component in the new dataset.
But how to do it with the rotated components/loadings, since after
varimax() we don't have a prcomp object anymore?
Thanks in advance!
David
[[alternative HTML version deleted]]
</pre>David Villegas Ríos2014-10-20T13:36:33matching genes to a list of gene groups an built binary dataframe
http://comments.gmane.org/gmane.comp.lang.r.general/314423
<pre>Dear All,
I have a gene list
Genes <- c("ACACA", "BAX" , "BCL2", "BID", "BAX", "MAPK9")
and a list of group of genes
ListGroup <- list(group1=c("ACACA" ,"AHSA1" ,"AIMP2" , "AKR1B1",
"AKT1", "AKT1S1"), group2=c("ANXA1" , "AR" , "ARID1A" ,
"ATM" , "BAK1" , "BAX" ), group3=c("BCL2" , "BCL2L1" ,
"BCL2L11" , "BECN1" , "BID" , "BIRC2"))
ListGroup
$group1
[1] "ACACA" "AHSA1" "AIMP2" "AKR1B1" "AKT1" "AKT1S1"
$group2
[1] "ANXA1" "AR" "ARID1A" "ATM" "BAK1" "BAX"
$group3
[1] "BCL2" "BCL2L1" "BCL2L11" "BECN1" "BID" "BIRC2"
I would like to built a data frame as:
ACACA BAX BCL2 BID BAX MAPK9
group1 1 0 0 0 0 0
group2 0 1 0 0 1 0
group3 0 0 1 1 0 0
Many thanks,
Karim
[[alternative HTML version deleted]]
</pre>Karim Mezhoud2014-10-20T13:28:30create vector objects by recurrence equation function
http://comments.gmane.org/gmane.comp.lang.r.general/314419
<pre>Subscribers,
A spreadsheet contains (what appears to a low aptitude mathematician!) a
recurrence equation:
cellb1=2cellc1=0.1celld1=5
cella2=1/(k1*cellb1)cellb2=cellb1+cellc1+celld1cellc2=cella2*cellb2celld2=cellb2*k2
where k are constants.
Could someone please direct to a relevant function name in the manual,
to create a vector (e.g. length 10) for subsequent values that would be
in equivalent spreadsheet cells cellc3, celld3, cellc4, celld4, etc.?
</pre>rl< at >openmailbox.org2014-10-20T10:53:21dbHasCompleted() always returns TRUE for POSTGRES Database withRJDBC?
http://comments.gmane.org/gmane.comp.lang.r.general/314416
<pre>Hello Simon, Hello everyone,
I have a problem with retrieving database-queries chunkwise. In my query
(Postgresql-Database, Postgres-Version 9.1) dbHasCompleted seems to
always return TRUE.
dbGetQuery works for smaller tables, but not for the whole query, since
then a Heap-Overflow-Error will occur (and a Error:
"java.lang.OutOfMemoryError: GC overhead limit exceeded" when trying to
set a larger size).
Does anybody else have or had this problem?
All the best
Julian
######## adapted Example from help (?dbHasCompleted ), Works #######
require("RSQLite")
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(con, "mtcars", mtcars)
# Fetch all results
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
dbFetch(res)
dbClearResult(res)
# Fetch in chunks
res <- dbSendQuery(con, "SELECT * FROM mtcars")
dbHasCompleted(res) ## RETURNS FALSE !!!
while (!dbHasCompleted(res)) {
chunk <- fetch(res, 10)
print(nrow(chunk))
}
dbClearResult(res)
dbDisconnect(con)
########## My</pre>julian.bothe< at >elitepartner.de2014-10-20T10:26:38saving parameters as a variable
http://comments.gmane.org/gmane.comp.lang.r.general/314415
<pre>Hi;
In the simulation studies we need to save some measure in the output as a
variable to do some calculation on them, how we can do that?
For example: the p-value , t-value, in t-test ( t.test( ) )
or
The estimated parameters in some models,(Ex: IRT model: graded response
model) in ltm package:
(see grm model in attachment file)
grm(data, constrained = FALSE, *IRT.param* = TRUE, ...)
*IRT.param:*
bij: difficulty parameter for item i and category j)
ai : discriminant parameter for item i)
thata(k) : ability parameter for person k
Note that this package does not give theta(k) even in output!
How can i load theta parameters?
Thanks in advanse
</pre>M Fatemi2014-10-20T08:27:48Dry Spell Problem.
http://comments.gmane.org/gmane.comp.lang.r.general/314410
<pre>Dear All,
I want to solve the following problem on a climatic dataset. It contains
Year, Day and Rain as Columns names.
Ex: > head(Samaru56)
Year Day Rain
1 1928 1 0
2 1928 2 0
3 1928 3 0
4 1928 4 0
5 1928 5 0
6 1928 6 0
The first day from April 01 that gets more than 20 mm on a single day, or
totalled
over 2 consecutive days with the additional condition that there is no 10
day (or longer) dry spell in the next 30 days.
Any help is appreciated. Thanks!!!
Regards,
Frederic.
</pre>Frederic Ntirenganya2014-10-20T07:47:44need help for predictive analytics part
http://comments.gmane.org/gmane.comp.lang.r.general/314409
<pre>
Hello sir,
Actually, I 'm novice to R programming and currently working on prediction part for CPU usage log file (attached with mail).
My task is to predict next hour CPU usage by taking "Time" as response and %user %nice %system %iowait %steal %idle, either all or one as predictor(s).
Please help me out.
I have attached CPU usage log file with mail.
Please find attachment.
Thank You in advance.
Regards,
Swapnil Khobragade
Larsen & Toubro Infotech Ltd.
Bldg. No.5&6, 1st Floor,
Airoli, Navi Mumbai - 400708.
e-mail ID: swapnil.khobragade< at >lntinfotech.com
Tel: < at >< at >< at >< at >< at >< at >< at >(Direct) | +91 9503043368 (M)
The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and using or disseminating the information, and must notify the sender and delete it from their system. L&T Infotech will not accept </pre>Swapnil Khobragade2014-10-20T07:03:34format negative numbers
http://comments.gmane.org/gmane.comp.lang.r.general/314408
<pre>Dear all.
Before I start fishing in (for me) murky regular expression waters I try to ask community about changing format of negative numbers.
For some reason I get a file with negative numbers formatted with negative sign at end of number.
something like
0.123-
It is imported as factors and I need to convert it to numbers again. Before converting I need to change it to "correct" format
-0.123
Does anybody know some simple way?
Cheers
Petr
________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi</pre>PIKAL Petr2014-10-20T07:03:36Search EngineSearch the mailing list at Gmanequery
http://search.gmane.org/?group=$group=gmane.comp.lang.r.general