Displaying 20 results from an estimated 200 matches similar to: "3 questions regarding matrix copy/shuffle/compares"
2010 Mar 11
2
Comparing matrices
Hello all,
I have two matrices, pop and pop2, each the same number of rows and
columns that I want to compare for equality. I am concerned about
efficiency in this operation.
I've tried a few things without success so far. Doing something simple like:
if (pop==pop2) { cat('equal') } else { cat('NOT equal') }
results in the warning:
1: In if (pop == pop2) { :
the
2011 Dec 13
2
Generating input population for microsimulation
Hi all,
I've been struggling with some code and was wondering if you all could help.
I am trying to generate a theoretical population of P people who are housed within X different units. Each unit follows the same structure- 10 people per unit, 8 of whom are junior and two of whom are senior. I'd like to create a unit ID and a unique identifier for each person (person ID, PID) in the
2010 May 20
1
Geneland error on unix: Error in MCMC(........ :, unused argument(s) (ploidy = 2, genotypes = geno)
I am receiving the above error ( full r session output below) the
script runs OK in windows. and "genotypes" and "ploidy" are both
correct arguments
any suggestions would be most welcome
Nevil Amos
MERG/ACB
Monash University School of Biological Sciences
> library(Geneland)
Loading required package: RandomFields
Loading required package: fields
Loading required
2007 Nov 15
3
Ancova doesn't return test statistics
Dear all,
I'm quite sure that this is a stupid question, but I'll ask anyway.
I want to perform an ANCOVA with two continuous factors and three
categorical factors.
Plant population growth rate (GR) = dependent variable
Seed reduction due to herbivory (SR) = continuous explanatory variable
Herbivore species (HS, 2 levels) = categorical explanatory variable
Population (Pop, 24 levels) =
2011 Oct 12
2
How to transfer the variable into function in this code?
as shown in the code, four variables input: diff_expr,diff_coex, klist,
Pop_size, are included in the function. However, within the function,
another variable "vector" is utilized in some subfunction. How they get its
value?
thx
get_quantiles <-function(diff_expr,diff_coex,klist,pop_size){
##### The function to get the "node_score_term" and "edge_score_term" of
2004 Jun 20
1
Sweave and echoing R comments
Is there any way to echo comments from an R source file into an
SWeave->LaTeX document?
Example:
# Npop is population total
# Npoph0..Npoph2 are stratum totals
# Npoph is vector of stratum totals
Npop<-sum(to2000)
Npoph0<-sum(to2000[bg==0])
Npoph1<-sum(to2000[bg==1])
Npoph2<-sum(to2000[bg==2])
Npoph<-c(Npoph0,Npoph1,Npoph2)
In the final LaTeX document, I'd like the
2010 Jan 17
2
For loops in R
Hello.
I've just started using R and am trying to figure out if the two codes
snippets below have the same output
gBest<-floor(runif(popsize,min=1,max=top))
velocity[i,j]<<-.4* velocity[i,j] + 1 * runif(1) * (pbestsVar[i,j] -
popVar[i,j]) + 1 * runif(1) * (archiveVar[gBest,j] - popVar[i,j])
and
for (i in 1:popsize) {
for (j in 1:maxvar) {
gBest<-sample(top,size=1)
2025 May 07
1
How to get the same result for GA optimization?
I am using *Genetic Algorithm* to maximize some function which use data.
I use GA package in R for this (
https://cran.r-project.org/web/packages/GA/index.html)
Below is my code
library(GA)
set.seed(1)
Dat = data.frame(rnorm(1000), matrix(rnorm(1000 * 30), nc = 30))
Fitness_Fn = function(x) {
return(cor(Dat[, 1], as.matrix(Dat[, -1]) %*% matrix(x, nc = 1))[1,1])
}
ga(type =
2025 May 07
1
How to get the same result for GA optimization?
Dear Daniel
As far as I can see you have re-generated the data before calling ga()
so the data is not just a permutation of the first set.
Michael
On 07/05/2025 15:36, Daniel Lobo wrote:
> I am using *Genetic Algorithm* to maximize some function which use data.
>
> I use GA package in R for this (
> https://cran.r-project.org/web/packages/GA/index.html)
>
> Below is my code
2009 Jan 13
3
problem whit Geneland
I do the these passages:
library(Geneland)
set.seed(1)
data <- simdata(nindiv=200,
coord.lim=c(0,1,0,1) ,
number.nuclei=5 ,
allele.numbers=rep(10,20),
IBD=FALSE,
npop=2,
give.tess.grid=FALSE)
geno <- data$genotypes
coord <- t(data$coord.indiv)
path.mcmc <-
2011 Dec 02
1
Error in Genetic Matching
Dear R Users,
I am a novice learner of R software. I am working with Genetic Matching - GenMatch(), but I am getting an Error message as follows:
Error in GenMatch(Tr = Tr, X = X.binarynp, BalanceMatrix = BalanceMatrix.binarynp, :
GenMatch(): input includes NAs
Could you please suggest me correcting the above problem?
My GenMatch command is,
> gen1 <- GenMatch(Tr = Tr, X =
2019 Jan 16
2
optimizacion costos
Estimado Jesús Para Fernández
En teoría es ese material, lo vi muy rápido y en la parte genética tiene
cosas que biológicamente no son así, hay un libro de Falconer, Introducción
a la genética cuantitativa, que tiene escrita la parte matemática, hay un
abismo entre la biología y los ingenieros que se inspiran en la biología.
Yo pensaba en la resolución de un problema real, aunque relativamente
2009 Feb 18
2
how to randomly eliminate half the entries in a vector?
(sorry if this is a duplicate-problems with posting at my end)
----
Hello all,
I need some help with a nice R-idiomatic and efficient solution to a
small problem.
Essentially, I am trying to eliminate randomly half of the entries in
a vector that contains index values into some other vectors.
More details:
I am working with two strings/vectors of 0s and 1s. These will contain
about 200
2007 Oct 01
1
saving and loading complex objects
Dear Sir:
When I try to save large and very complex recursive objects with some components containing models (such as the output from arima or lm ),
the resulting file sizes increase by 4 meg per save.
example directory:
amex 8 meg
argentina 12 meg
australia 16 meg
...
Moreover, I am unable to read these file objects back into R.
I note that readBin and writeBin
2010 Dec 15
0
Problems with the borders (High difficulty)
Dear r-help members,
Could any of you help me with this model, please?
This model gives error when some value touch whatever border and I do not know how to correct it. The 80% of the seeds produced by a plant will fell into the parent cell, the 15% in the first ring according to the king movement (in chess), and a 5% in the second ring defined by the queen2 matrix. Someone said me the functions
2015 Sep 09
0
sample.int() algorithms
I was experiencing a strange pattern of slowdowns when using
sample.int(), where sampling from a one population would sometimes
take 1000x longer than taking the same number of samples from a
slightly larger population. For my application, this resulted in a
runtime of several hours rather than a few seconds. Looking into it,
I saw that sample.int() is hardcoded to switch algorithms when the
2009 Sep 09
2
Matrix multiplication and random numbers
Dear All
I new to using R and am struggling with some matrix multiplication.
I have two matrices, one containing random numbers, these are multiplied
together to get another matrix which is different each time. When I put in
another for loop to repeat this process a multiple times the matrices are
all the same. I?m sure there is a way to keep the randomness of the
different matrices but I think
2005 Feb 18
1
Is this a bug or by design? Workaround?
Hi,
I need to use the trailing 5 digits of a callerid. callerid may be anything
from a length of 4 to 10 digits in this case.
Using this:
-----------
SubString,cid=${CALLERIDNUM}|-5|5
Works great, BUT shows this message:
"The use of Substring application is deprecated. Please use ${variable:a:b} instead"
So, I try
---------
SetVar(cid=${CALLERIDNUM:-5:5})
The result is a empty
2005 Feb 21
0
bug? Unterminated comment detected beginning on line 0
Hi,
Using latest cvs.
A comment-line begins with semicolon ;
However - if the line contains
;--
or like this
; -- blabla bla --
You get this error and * stops reading that file:
Feb 21 13:47:12 WARNING[17393]: config.c:664 config_text_file_load: Unterminated comment detected beginning on line 0
Shouldn't Asterisk skip any line beginning with a semicolon?
Or should a comment now be
2008 Sep 12
2
Fw: Complex sampling survey _ Use of survey package
--------------------------------------------------
From: "Ahoussou Sylvie" <sylvie.ahoussou at antilles.inra.fr>
Sent: Friday, September 12, 2008 9:48 AM
To: "Thomas Lumley" <tlumley at u.washington.edu>
Subject: Re: [R] Complex sampling survey _ Use of survey package
> Thanks for your answer
>
> I think I made a mistake when I recopied the 5 first rows of