Often I need a random number (as a seed for a split, or to randomly order records). Now you might think that, if we have a randomnumber generator, you could make things MORE random if you multiply these (random * random is randomer). Let's see if this holds true by just trying!
Say we have 20,000 random numbers between 0 and 1 we can plot the number against their frequency using a histogram (100 bins):
Now this looks pretty random, 100 bins means that the space is divided in 100 sections. So 1 bin (section) with all values between 0.00 - 0.01 , 1 bin with all values between 0.01-0.02.
We observe that most bins have a value between 0.009 & 0.011 and all between 0.008 & 0.012. which means that there are about 0.010 * 20,000 = +/- 200 points generated with a value between 0 and 0.01.
There are also 200 point generated with a value between 0.01 and 0.02 and so on. This indeed looks rather random. We can also plot the index (1st number
generated to 20,000th number generated) versus the value:
Again this looks al pretty random, and so it should. The whole space is filled evenly.
Now here comes the kicker: If we multiply these random numbers (the same in the same order) with another random number things start to look less random:
Again we can plot the index versus the number:
What we see is that the numbers are actually getting less random. So a given value occurs more frequently. Now let's look at the bin plot again:
Remember just now, there were approximately 200 points with a value between 0.00 and 0.01. Now we see 0.06 * 20,000 = 1200, conversely we see only 0.00005 * 20,000 = 1 datapoint with a value between 0.99 and 1.00! This is looking much less random.
And this effects gets worse when we use 3 times random numbers multiplied:
0.165 * 20,000 = 3310 values between 0.00 - 0.01 and 0 values between 0.99 - 1.00. The highest bin is between 0.89 and 0.90 with 0.0001 * 20,000 = 2 data points.
And 4 times random numbers multiplied…
0.33030 * 20,000 = 6606 values between 0.00 and 0.01 & again 0 in the highest bin. There is 0.00005 * 20,000 = 1 datapoint with a value between 0.86 and 0.87. (perhaps not very visible in the second plot)
So there you have it, while you might think that random *
random is more random than random, it is NOT! This is stated by the central
limit theorem. In probability theory, the central limit theorem (CLT) states
that, given certain conditions, the arithmetic mean of a sufficiently large
number of iterates of independent random variables, each with a well-defined
expected value and well-defined variance (all will be between 0 and 1), will be
approximately normally distributed, regardless of the underlying distribution. (see [1] http://www.math.uah.edu/stat/sample/CLT.html, [2] Rice, John (1995), Mathematical Statistics and Data Analysis (Second ed.), Duxbury Press, ISBN 0-534-20934-3), also [3] wikipedia, https://en.wikipedia.org/wiki/Central_limit_theorem )
This is a repost from a blog entry by Dr Jennifer Raff the original can be found here. In light of recent outbreaks of measles and other vaccine preventable illnesses, and the refusal of anti-vaccination advocates to acknowledge the problem, I thought it was past time for this post.
Dear parents,
You are being lied to. The people who claim to be acting in the best interests of your children are putting their health and even lives at risk.
They say that measles isn’t a deadly disease.
But it is.
They say that chickenpox isn’t that big of a deal.
But it can be.
They will say that doctors won’t admit there are any side effects to vaccines.
But the side effects are well known, and except in very rare cases quite mild.
They say that the aluminum in vaccines (an adjuvant, or component of the vaccine designed to enhance the body’s immune response) is harmful to children.
But children consume more aluminum in natural breast milk than they do in vaccines, and far higher levels of aluminum are needed to cause harm.
They say that the Vaccine Adverse Events Reporting System (and/or the “vaccine court”) proves that vaccines are harmful. It doesn’t.
They say that if other people’s children are vaccinated, there’s no need for their children to get vaccinated.
This is one of the most despicable arguments I’ve ever heard. First of all, vaccines aren’t always 100% effective, so it is possible for a vaccinated child to still become infected if exposed to a disease. Worse, there are some people who can’t receive vaccinations, because they are immune deficient, or because they are allergic to some component. Those people depend upon herd immunity to protect them. People who choose not to vaccinate their children against infectious diseases are putting not only their own children at risk, but also other people’s children.
They say that ‘natural’, ‘alternative’ remedies are better than science-based medicine. They aren’t.
The truth is that vaccines are one of our greatest public health achievements, and one of the most important things you can do to protect your child.
I can predict exactly the sort of response I will be getting from the anti-vaccine activists. Because they can’t argue effectively against the overwhelming scientific evidence about vaccines, they will say that I work for Big Pharma. (I don’t and never have). They will say that I’m not a scientist (I am), and that I’m an “Agent 666” (I don’t know what that is, but I’m pretty sure that I’m not one).
None of these things are true, but they are the reflexive response by the anti-vaccine activists because they have no facts to back up their position. On some level, deep down, they must understand this, and are afraid of the implications, so they attack the messenger.
In only one respect is my message the same as the anti-vaccine activists: Educate yourself. But while they mean “Read all these websites that support our position”, I suggest you should learn what the scientific community says. Learn how the immune system works. Go read about the history of disease before vaccines, and talk to older people who grew up when polio, measles, and other diseases couldn’t be prevented. Go read about how vaccines are developed, and how they work. Read about Andrew Wakefield, and how his paper that claimed a link between the MMR vaccine and autism has been withdrawn, and his medical license has been revoked. Read the numerous, huge studies that have explicitly examined whether autism is caused by the vaccine…and found nothing. (While you’re at it, read about the ongoing research to determine what IS the cause—or causes —of autism, which is not helped by people continuing to insist that vaccines cause it).
That may seem like a lot of work, and scientific papers can seem intimidating to read. But reading scientific articles is a skill that can be mastered. Here’s a great resource for evaluating medical information on the internet, and I wrote a guide for non-scientists on how to read and understand the scientific literature. You owe it to your children, and to yourself, to thoroughly investigate the issue. Don’t rely on what some stranger on the internet says (not even me!). Read the scientific studies that I linked to in this post for yourself, and talk to your pediatricians. Despite what the anti-vaccine community is telling you, you don’t need to be afraid of the vaccines. You should instead be afraid of what happens without them.
This video is an outstanding summary of many of these issues. I encourage you to watch it.
“Humans try to make sense of the world by seeing patterns. When they see a disease or condition that tends to appear around the time a child is a year or so old, as autism does, and that is also the age that kids get particular shots, they want to put those things together. Parents watch kids more carefully after they get shots. Sometimes they pick up on symptoms then. Just because two things happen at the same time doesn’t mean that one caused the other. This is why we need careful scientific studies.”
Additionally Pen and Teller have made a great visual aid to demonstrate the need for vaccination
Note: For people coming via a direct link, please also feel free to participate in a follow-up discussion
Ik moet zeggen dat ik hoogst verbaasd was over de toon die jij in deze brief aanslaat. Een toon die ik ook bij andere mensen uit jouw vakgebied tegen kwam, zelfs op nationale televisie. Als ik jouw tekst lees als wetenschapper, dan ben ik geneigd te denken dat een deel van de mensen werkzaam in jouw vakgebied dit vakgebied niet als wetenschap ziet. Jij demonstreert hier een groot gebrek aan wetenschappelijke ethiek, ja zelfs een minachting voor hen die dat wel bezitten!
Je begint je betoog met een stelling waar je het leugentje om bestwil in een voorbijgaande sociale interactie gelijk stelt aan een wetenschappelijke publicatie puur gebaseerd op het feit dat beiden door mensen uitgevoerd worden. Met andere woorden, je stelt dat je op professioneel gebied niet meer mag verwachten van mensen dan het niveau van amateurs, tijdens het roddeluurtje met de koffie pauze. Om jouw analogie te vervolgen: Stel iemand verft zijn kamer en gebruikt de verkeerde, slecht dekkende, verf. Dit kan je dus eigenlijk ook van schilders verwachten en is helemaal zo gek niet, want het betreft in beide gevallen mensen.
Mijn aandacht was hierdoor inderdaad gevestigd en ik was benieuwd wat je aan ging voeren om dit te onderbouwen.
Je stelt vervolgens dat 70 % (!!!!) van de psychologen liegt over hun data. Zonder bronvermelding maak je het leeuwendeel van je vakgebied uit voor leugenaars! Ik wil je graag naar deze [1] pagina van de KNAW verwijzen betreffende wetenschappelijke integriteit. Besef je dat een wetenschapper een expertise op een bepaald gebied heeft, hierom heeft hij de plicht ethisch te handelen. Als expert ben je in de positie dat je makkelijk mensen kan misleiden, vooral om de doodeenvoudige reden dat je een autoriteitspositie hebt. Dat je bewezen ethisch verwerpelijk gedrag vergoelijkt door het merendeel van jouw vakgebied zwart te maken verdient natuurlijk niet de schoonheidsprijs.
De wetenschap bestudeert en verklaart de wereld in verscheidene vakgebieden. Zij kent drie belangrijke pijlers:
De wetenschappelijke methode
Publicatie van resultaten
Reproduceerbaarheid van resultaten
De kern van de wetenschappelijke methode is dat je antwoorden zoekt op onderzoeksvragen. Het is belangrijk eerst een vraag te formuleren en dan systematisch onderzoek hiernaar te doen omdat dit voorkomt dat je valse verbanden gaat zien in data.
Ten tweede is het van belang je data te publiceren, dit om je 'peers' van jouw inzichten op de hoogte te stellen zodat het vakgebied als geheel progressie boekt. Nieuwe resultaten zullen nieuwe vragen opwerpen, welke weer onderzocht worden.
Ten derde is reproduceerbaarheid van jouw bevindingen erg belangrijk. Je kan gerust stellen dat als iets niet reproduceerbaar is, het geen vaststaand feit is. Immers, als je iets niet kan reproduceren onder identieke omstandigheden, is er iets fundamenteel anders en levert jouw hypothese geen verklaring van jouw resultaten. Met andere woorden, als iets niet reproduceerbaar is, heb je iets over het hoofd gezien.
Dit houdt dus in dat een publicatie vereist dat je ruwe data mee stuurt. Hoe anders kunnen jouw 'peers' jouw resultaten reproduceren, hoe anders kunnen zij deze interpreteren en gebruiken voor hun eigen hypothesen?
"In een vakgebied waar de weg naar succes geplaveid dient te worden met publicaties in topbladen als Nature en Science, en die bladen alleen papers accepteren met ronkende resultaten, is het niet verwonderlijk dat je als onderzoeker de werkelijkheid zo nu en dan een handje wilt helpen."
Hoe kan iemand gefabriceerde resultaten publiceren en zonder wroeging de carriĆØre van andere wetenschappers erop zien rusten? Fabriceer jij data dan worden nieuwe promovendi, 'peers' hier de dupe van, iets dat zich manifesteert in de affaire Stapel. Hoe gaat iemand ooit nog een naam opbouwen waneer hij/zij slechts met Stapel gepubliceerd heeft? Hoe gaat zo iemand ooit nog zijn vak kunnen uitoefenen?
De kern van de wetenschap is de werkelijkheid bestuderen en verklaren "..de werkelijkheid zo nu en dan een handje helpen.." is geen wetenschap. Wanneer iemand dit toch doet is hij/zij per definitie niet bezig met de beoefening van wetenschap.
"De wetenschap is het meest gebaat bij een cultuur waarin onderzoekers niet worden afgestraft voor hun mislukkingen maar juist worden aangemoedigd om er openhartig over te zijn. Dat bereiken we niet door degenen die fouten maken aan de schandpaal te nagelen."
Er is een groot verschil tussen mislukkingen (oftewel verworpen hypothesen) en moedwillig liegen / bedriegen. Inderdaad zijn negatieve resultaten ook resultaten, maar deze persoon heeft zijn negatieve resultaten niet gepubliceerd maar verzwegen. Deze persoon heeft resultaten gefingeerd en hiermee de wetenschap niet verder geholpen maar eerder een hoop schade berokkent! Als jij denkt dat hij aan de schandpaal genageld wordt voor het feit dat hij geen resultaten boekte sla je de plank mis.
Tot slot wil ik je graag wijzen op 'Good Clinical Practice' [2] (GCP). GCP is de standaard waaraan klinisch onderzoek dient te voldoen, deze standaard omvat alle regels die jij aanhaalt en meer. Misschien is het goed om de regels van GCP in de (sociale) psychologie ook toe te passen. Vergeet niet dat dit reeds verplicht is in een deel van de psychologie, dat gebied wat belast is met het onderzoek naar interventies/behandelmethoden. Dit verplicht een minimum standaard voor onderzoeken en ontdoet een geplaagd vakgebied van twijfel.
[1] Thema Pagina Wetenschappelijke Integriteit, Website KNAW (www.knaw.nl), bezocht 10-11-2011
[2] International Conference on Harmonisation Topic E 6 (R1), Guideline for Good Clinical Practice, Website European Medicines Agency (www.emea.europa.eu ), bezocht 10-11-2011
(I am seeing about 5-10 views a day on the Pipeline Pilot pages, please be so kind to acknowledge / cite my blog when you use these tools and guides) Why would we want such a thing? Like with the regression validation parameters, I found that PP lacked a component to calculate correlation coefficients between two properties in the data stream in classification. Therefore I have written a component to do just that. One of the features I find useful is the option to include a bar chart that displays the values of the calculated properties on a scale between 0 and 1. This allows a quick visual inspection of your model reliability. When applied to the 'KNN classification of Estrogen Antagonists' from the example protocols, it looks like this:
In addition it outputs the parameters in a shaded table:
The component calculates these parameters between two properties. Therefore, when using in external validation of a model, the modeled values have to be pre-calculated. The component requires that you give the names of the properties carying the measured value, the modeled value and the classes that were modeled. Currently it can only be used in a two class classification. In addition you can choose to also output the original unmodified records through the fail port, while the correlation plot and table are output through the pass port. I have not written a 'how to use' in the help, but will do so next week. In the meantime, the component can be found here.
(I am seeing about 5-10 views a day on the Pipeline Pilot pages, please be so kind to acknowledge / cite my blog when you use these tools and guides) Why would we want such a thing?
During the time I have been using PP, I found it inconvenient that there was no component to calculate the correlation coƫfficient between two properties present in the data stream (for instance when performing external validation of a model).
Therefore I have written a component to do just that. One of the features I find useful is the option to include both an upper and lower error margin line. Allowing a quick visual inspection of your model reliability.
While in the latest version (8.5) there is a component called "Regression Model Evaluation Viewer" which calculates an RMSE and R2, this component has some downsides.
The component calculates the modeled values internally, so it cannot be used to calculate the correlation between two sets of values obtained from external sources.
The component only calculates the R2 and RMSE, while for a proper evaluation R02 and k-slope are also required.
My component is on my website and compatible with PP 8.5 and up, it can be found
It has been tested up to a maximum of approx. 20,000 records and works fine. In addition the parameters that are also calculated in the 'Regression Model Evaluation Viewer' and 'R-statistics fit plots' are identical.
So what does it do?
The component calculates correlation parameters according to Tropsha (2010) 1 between two properties present in the stream. These properties are defined as 'Activity' (Y-values) and 'Model' (X-values). These have to be present in the stream and therefore need to be pre-calculated in the case of a model. In addition, a scatter plot containing all values is output. Both the parameters and the plot are output as reporting items.
The following values are calculated:
RMS Error (RMSE)
R2 (R2)
R02 (R2_zero)
R02' (R2_zero_acc)
k-Slope (Slope_K)
k-Slope ' (Slope_K_acc)
% Difference between R2 and R02 (Perc_Diff_R2_with_R2_zero)
% Difference between R2 and R02' (Perc_Diff_R2_with_R2_zero_acc)
Absolute difference between R02 and R02' ( Absolute_diff_R2_zero_and_R2_zero_acc)
Additional Settings:
Under 'Plot Parameters' variables for the x-y scatter plot can be defined. Furthermore the range of the upper and lower error lines can be set (default 0.5 from the line of unity).
'Auto_range'; when set to 'True' the scale of the axis is automatically defined to the scale of the data. Alternatively; when set to 'False' (default), a range can be entered manually for 'Activity' (y-value) and 'Model' (x-value)(Default is 2.0 - 12.0).
'Uncertainty' defines the margin between the line of unity and the uncertainty lines (default 0.5 units away from line of unity).
If 'Uncertainty_in_plot' is set to 'True' (default) then two lines indicating a lower and upper error line are drawn in the plot.
If 'Output_Records' is set to 'True' all values are output unchanged to the 'Fail' port while the plot and correlation parameters are output to the 'Pass' port.
The examples are made in the example protocol "08 Calculate logP using the R_logP_SVM Model" , listed under Examples/R Statistics/Learning and Clustering/R Learn Models...
RMSE
R2_zero
R2
R2_zero_acc
Slope_K acc
Slope_K
Perc_Diff_R2 with_R2_zero
Perc_Diff_R2 with_R2_zero_acc
Absolute_diff_R2_zero and_R2_zero_acc
0.679
0.839
0.839
0.827
0.997
0.928
0.000
0.015
0.012
If for some reason you are heaving trouble with the component, please contact me!
Tropsha, A. (2010). Predictive Quantitative Structure-Activity Relationships Modeling. Handbook of Chemoinformatics Algorithms. J. Faulon and A. Bender.
Updated! (I am seeing about 5-10 views a day on the Pipeline Pilot pages, please be so kind to acknowledge / cite my blog when you use these tools and guides).
Over the last years I have been using R to create my models. However the interface running on top of R (doing the data shaping and fingerprint folding) was pipeline pilot. This works quite nice and efficient (although one could think of better solutions, but for my works this set up suffices).
When there are errors in your data though, things go wrong. Not all error messages are as intuitive as you would like. The pipeline pilot help can't really help here either, so over the last years I have kept a list of error codes and what they mean in practice. I have listed it here so that anyone else struggling with an unknown error might find it. however this is also convenient for myself as online these things are retrieved quicker than on network share xxx :).
The organisation is as follows, the closed dot with italic characters is the actual error message received (trimmed), the white dot with regular text contains a possible cause, the closed square a solution.
Related to SVM as performed in the “e1071”
package:
Error in svm.default(x, y, scale = scale, ..., na.action = na.action) :
dependent variable has to be of factor or integer type for classification mode.
Fingerprint properties are not recognized as fingerprints
Set property type of properties to learn from to “fingerprint”
(like 'SciTegic.value.IntegerFingerprintValue')
Set option convert fingerprints to “Fixed-Length array of
bits”
Possibly due to merge there are array properties present (multiple values for one property)
Error in …. Subscript
out of bounds
The property to learn is incorrect
Two values present in one
property where there should be one
Only actives are present
No properties present to learn from
Possibly through ignore properties)
Empty beginning of
file
The property to learn is incorrect.
Either not present in the stream
The name is misspelled
Missing properties in
file
Problem with the fingerprints that are being input in a
learned model.
The ‘change fingerprints to fixed length bit size’ is
executed wrongly,
This specific property is missing
Set property type to fingerprint has not been performed ('SciTegic.value.IntegerFingerprintValue')
"Error in svd(x,
nu = 0) : 0 extent dimensions"
When performing a PCA, (multiple) properties are not
considered to be numeric.
Decimal comma instead of dot
“Error in svm.default(x,y,scale,…..):
C <= 0!”
The allocation of a cost value is incorrect.
Decimal comma instead of dot
“Error in matrix(ret$dec, nrow =
nrow(newdata), byrow = TRUE, dimnames = list(rowns, : matrix:
invalid 'ncol' value (< 0)Execution halted”
Properties to learn from defined incorrect
“allpropertiesonfirstdata” instead of “user set” when not all
properties are present in all records
Error in
svm.default(x, y, scale = scale, ..., na.action = na.action) : Need numeric dependent variable
for regression. In addition: Warning message:data length exceeds size of
matrix
Property to learn from contains non-numeric characters
Continuous
model selected for classification data
Error in
cor(preds[[1]], preds[[2]], method = "pearson") : missing
observations in cov/cor. In addition: Warning messages: 1-5: data length
exceeds size of matrix
Non numeric properties are used to learn from in regression.
Use ‘IgnoreProperties’ to exclude non numeric properties
Possibly, property should be changed to ('SciTegic.value.IntegerFingerprintValue') while using
regression.
Error in c(1e-05/nx, 0.001/nx, 1/nx, ) : argument 4 is empty
Gamma values to be sampled ends with comm rather than value
Remove comma at the end or add value
Error in
svm.default(x, y, scale = scale, ..., na.action = na.action) : NA/NaN/Inf in foreign function call (arg
4) Calls: doCV ... modelfunc -> svm -> svm.formula -> svm.default
-> .C
Property to learn from non-numeric
‘Inf’ rather
than numeric
Error in withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) : invalid multibyte string at '<b2>II' (or at '<a0>hydra) Calls: readxy -> cleandata -> FactorOrNumber Execution halted
Array property present formatted as blabla[1], blabla[2], etc.
Flatten to single properties (eg turn binary flag on for proeprties present named by value in array property.
Related to decision tree forests as
performed in the “randomForest” package:
Error in
randomForest.default(xy[-1], y, ntree = 500, mtry = mtry, importance =
imp) : NA/NaN/Inf in foreign
function call (arg 2) Calls: randomForest -> randomForest.default ->
.C
Property to learn from non-numeric
‘Inf’ rather
than numeric
Error in randomForest.default(xy[-1], y, ntree = 70, mtry = mtry, importance = imp, :
NA not permitted in predictors
Property to learn from numeric when classifying
Error in comps[c1, c2]
<- round(roc12, digits = 4) : replacement has length zero Calls: print
-> genroc
One of the classes might be present once, making ou-of-bag
validation impossible
Error in `rownames<-`(`*tmp*`, value = row.names(x)) : attempt to set rownames on object with no dimensions Calls: randomForest ... randomForest.default -> is.na -> is.na.data.frame -> rownames<-
One of observations has an incomplete set of variables, one or more descriptors are missing (n/a)
Error in predict.randomForest(model, x, type = "response") : New factor levels not present in the training data Calls: predict -> predict.randomForest
One of observations has a level for set one of the variables that was not observed in the training set (e.g. present in the training set : 0,1,2,3 ; value in the test set 6)
Make sure each observation is seen in the training set
alternatively use continuous variables to describe the datapoints rather than categorical
Error in withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) : invalid multibyte string at '<b2>II' (or at '<a0>hydra) Calls: readxy -> cleandata -> FactorOrNumber Execution halted
Array property present formatted as blabla[1], blabla[2], etc.
Flatten to single properties (eg turn binary flag on for proeprties present named by value in array property.
Hope this helps anyone when stuck (and that this page is indexed by Google, well probably isn't the case)
As we all know the peer-review system has it's pros and cons, but, quite frankly is the best thing we've got to ensure high quality publications...
...What if we could improve the current system a little...?
In my opinion the peer review system can be improved with the following 2 steps only.
Firstly, manuscripts should be send to the referees with the authors name removed. This way it is just about the science. Secondly, more important, the names of the referees that reviewed a paper should be added to the list of authors. This actually has several major advantages, the referee gets rewarded for making the effort of reviewing a paper (as we all know this can take up a lot of time and effort). In addition he will take care not to allow bad science to be published as his own name is also now connected to the paper.