search for: casperyc

Displaying 20 results from an estimated 39 matches for "casperyc".

Did you mean: casper
2012 May 16
3
triangular matrices input/output
Hi, Is there any package that deals with triangular matrices? Say ways of inputting an upper (lower) triangular matrix? Or convert a vector of length 6 to an upper (lower) triangular matrix (by row/column)? Thanks! ----- ###################### PhD candidate in Statistics Big R Fan Big LEGO Fan Big sTaTs Fan ###################### -- View this message in context:
2011 Sep 11
2
how to quote "factors" in a function?
### code ### x=sample(LETTERS[1:26],100,T) prob=function(y){ count=sum(x==y) total=length(x) count/total } ### end ### How do I quote the letters A,B,C,D ect, in order to make the "prob" function return the weights of the desired Letter? Thanks! -- View this message in context:
2010 Dec 18
3
use of 'apply' for 'hist'
Hi all, ########################################## dof=c(1,2,4,8,16,32) Q5=matrix(rt(100,dof),100,6,T,dimnames=list(NULL,dof)) par(mfrow=c(2,6)) apply(Q5,2,hist) myf=function(x){ qqnorm(x);qqline(x) } apply(Q5,2,myf) ########################################## These looks ok. However, I would like to achieve more. Apart from using a loop, is there are fast way to 'add' the titles to be
2010 Nov 08
3
how do i plot this "hist"?
Hi all, I have the following data in abc.dat ======================= 50 0 1 0 0 55 1 14 0 1 60 7 86 0 3 65 22 324 2 3 70 58 1035 1 7 75 30 2568 0 34 80 9 2936 15 162 85 27 2169 46 365 90 80 1439 212 432 95 236 1670 521 281 100 332 827 709 172 105 156 311 556
2010 Mar 07
3
barplot with factors problem
http://www.harding.edu/fmccown/R/#autosdatafile http://www.harding.edu/fmccown/R/#autosdatafile I am tring to get a barchat by factors, following the example in that link above. =========================== x=c(145,40,40,120,180, 140,155,90,160,95, 195,150,205,110,160, 45,40,195,65,145, 195,230,115,235,225, 120,55,50,80,45 ) y2=c( rep(as.character(1),5), rep(as.character(2),5),
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi, I have a matrix, say m=matrix(c( 983,679,134, 383,416,84, 2892,2625,570 ),nrow=3 ) i can find its row/col sum by rowSums(m) colSums(m) How do I divide each row/column by its rowSum/colSums and still return in the matrix form? (i.e. the new rowSums/colSums =1) Thanks. Casper -- View this message in context:
2010 Nov 20
3
how to add frequencies to barplot
Hi, I have count data x2=rep(c(0:3),c(13,80,60,27)) x2 0 1 2 3 13 80 60 27 I want to graph to be ploted as barplot(table(x2),density=4) how do I add relative frequency to it, like in hist(x2,labels=T) above the 'bar's Thanks. casper -- View this message in context: http://r.789695.n4.nabble.com/how-to-add-frequencies-to-barplot-tp3051923p3051923.html Sent from the R help
2010 Mar 26
2
R loop help
Hi, I am tring to write a loop to compute this, ========================== x1=c( rep(-1,4), rep(1,4) ) x2=c( rep(c(-1,-1,1,1),2) ) x3=c( rep(c(-1,1),4) ) x1*x2 x1*x3 x2*x3 ======================== suppose i have x1,x2,x3 i want to compute their ' two factor interactions', x1x2,x1x3 and x2x3, I wrote ======================== for(i in 1:2){ for( j in i+1:3){ xij=c()
2012 Mar 22
2
Quicker way to apply values to a function
Hi all, myint=function(mu,sigma){ integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value } mymu=seq(-3,3,length(1000)) mysigma=seq(0,1,length(500))[-1] k=1 v=c() for (j in 1:length(mymu)) { for (i in 1:length(mysigma)) { v[k]=myint(mymu[j],mysigma[i]) k=k+1 } } Basically, I want to investigate for what values of mu and sigma, the integral is divergent. Is there another way
2012 Mar 10
3
function input as variable name (deparse/quote/paste) ??
Hi all Say I have a function: myname=function(dat,x=5,y=6){ res<<-x+y-dat } for various input such as myname(dat1) myname(dat2) myname(dat3) myname(dat4) myname(dat5) how should I modify the 'res' line, to have new informative variable name correspondingly, such as dat1.res dat2.res dat3.res dat4.res dat5.res stored in the workspace. This is only an example of a complex
2010 Dec 21
3
how to see what's wrong with a self written function?
Hi all, I am writing a simple function to implement regularfalsi (secant) method. ################################################### regulafalsi=function(f,x0,x1){ x=c() x[1]=x1 i=1 while ( f(x[i])!=0 ) { i=i+1 if (i==2) { x[2]=x[1]-f(x[1])*(x[1]-x0)/(f(x[1])-f(x0)) } else { x[i]=x[i-1]-f(x[i-1])*(x[i-1]-x[i-2])/(f(x[i-1])-f(x[i-2])) } } x[i] }
2010 Apr 13
3
writing function ( 'plot' and 'if') problem
=========================== myf=function(ds=1){ x=rnorm(10) y=rnorm(10) { #start of if if (ds==1) { list(x,y) } else (ds==2) { plot(x,y) } } # end of if } # end of function =========================== Hi All, the problem i am having here is, that I want to be able to control the display, lf ds=1, i want to just have a list, but it seem to always plot... Thanks. casper -- View this
2009 Dec 07
5
confint for glm (general linear model)
Hi, I have a glm gives summary as follows, Estimate Std. Error z value Pr(>|z|) (Intercept) -2.03693352 1.449574526 -1.405194 0.159963578 A 0.01093048 0.006446256 1.695633 0.089955471 N 0.41060119 0.224860819 1.826024 0.067846690 S -0.20651005 0.067698863 -3.050421 0.002285206 then I use confint(k.glm)
2012 Mar 23
3
R numerical integration
Hi all, Is there any other packages to do numerical integration other than the default 'integrate'? Basically, I am integrating: integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value The integration is ok provided sigma is >0. However, when mu=-1.645074 and sigma=17535.26 It stopped working. On the other hand, Maple gives me a value of 0.5005299403. It is an
2009 Dec 06
2
bootstrap help
Hi, I have 49 pairs in my data.frame 'data' x y 76 80 138 143 67 67 29 50 381 464 23 48 37 63 120 115 ... ... how do I get a bootstrap sample of size n=50? i have tried sample(data,size=50,replace=TRUE) and sample(data,replace=TRUE) both didnt seem to work (the latter one only return me with 49 sample) Thanks. casper -- View this message in context:
2010 Apr 10
1
writing function (plot problem)
Hi, ======================= x=rnorm(20) y=rnorm(20) t=lm(y~x) plot(t) ======================= you will get "click or hit enter to next page..." how do I write a function to archieve this ? say plot(x,y) then pause, wait plot(y,x) Thanks! casper -- View this message in context: http://n4.nabble.com/writing-function-plot-problem-tp1835723p1835723.html Sent from the R help mailing
2010 Dec 08
1
how to add these "axis" label?
Hi All, How do I add these axis labels? ############################################### p=seq(0,1,length.out=500) p=p[-c(1,length(p))] g1=log(p/(1-p)) g2=qnorm(p) g3=log(-log(1-p)) g4=-log(-log(p)) plot(p,g1, 'n',ylim=c(-5,5),las=1, bty='n', xaxt='n',yaxt='n', xlab="",ylab="" ) lines(p,g1,lty=1,col=1) lines(p,g2,lty=1,col=2)
2012 Mar 23
1
Vectorize (scalar) function
Hi all, myint=function(mu,sigma){ integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value } x=seq(0,50,length=3000) x=x[-1] plot(x,myint(4,x)) # not working yet I think I have to 'Vectorize' it somehow? What's a scalar function? and a primitive function? Thanks. casper ----- ################################################### PhD candidate in Statistics School
2012 Apr 03
1
Create Model Object (setClass?setMethod?)
Hi all, I have a self written likelihood as a model and functions to optimize and get fitted values, confidence intervals ect. I wonder if there is a way to define a 'class', or a 'model' (or a certain object)? so that I can use 'summary' to produce a summary like it does for a lm object. Also, it should be able to use 'predict' and 'plot' and other
2012 May 09
2
problem with Gauss Hermite ( x and w )
Hi all, I am using the 'gaussHermite' function from the 'pracma' library ############ CODES ########### library(pracma) cc=gaussHermite(10) cc$x^2 cc$x^5 cc$x^4 ############ CODES ########### as far so good. However, it does NOT work for any NON integer values, say ############ CODES ########### cc$x^(2.5) cc$x^(-2.5) ############ CODES ########### But just think about it