All About Statistics Tue, 12 Sep 2017 18:14:27 +0000 en-US hourly 1 http://wordpress.org/?v=3.4.2 statsblogshttps://feedburner.google.com It seemed to me that most destruction was being done by those who could not choose between the two http://feedproxy.google.com/~r/statsblogs/~3/8pNsHZNfA6E/ /2017/09/12/it-seemed-to-me-that-most-destruction-was-being-done-by-those-who-could-not-choose-between-the-two/#comments Tue, 12 Sep 2017 18:14:27 +0000 Dan Simpson http://andrewgelman.com/?p=36585

Amateurs, dilettantes, hacks, cowboys, clones — Nick Cave [Note from Dan 11Sept: I wanted to leave some clear air after the StanCon reminder, so I scheduled this post for tomorrow. Which means you get two posts (one from me, one from Andrew) on this in two days. That’s probably more than the gay face study deserves.] […]

The post It seemed to me that most destruction was being done by those who could not choose between the two appeared first on Statistical Modeling, Causal Inference, and Social Science.

The post It seemed to me that most destruction was being done by those who could not choose between the two appeared first on All About Statistics.

]]>
(This article was originally published at Statistical Modeling, Causal Inference, and Social Science, and syndicated at StatsBlogs.)

Amateurs, dilettantes, hacks, cowboys, clones — Nick Cave

[Note from Dan 11Sept: I wanted to leave some clear air after the StanCon reminder, so I scheduled this post for tomorrow. Which means you get two posts (one from me, one from Andrew) on this in two days. That’s probably more than the gay face study deserves.]

I mostly stay away from the marketing aspect of machine learning / data science / artificial intelligence. I’ve learnt a lot from the methodology and theory aspects, but the marketing face makes me feel a little ill.  (Not unlike the marketing side of statistics. It’s a method, not a morality.)

But occasionally stories of the id and idiocy of that world wander past my face and I can’t ignore it any more. Actually, it’s happened twice this week, which—in a week of two different orientations, two different next-door frat parties until two different two A.M.s, and two grant applications that aren’t as finished as I want them to be—seems like two times too many to me.

The first one can be dispatched with quickly.  This idiocy came from IBM who are discovering that deep learning will not cure cancer.  Given the way that governments, health systems, private companies, and  research funding bodies are pouring money into the field, this type of snake oil pseudo-science is really quite alarming. Spectacularly well-funded hubris is still hubris and sucks money and oxygen from things that help more than the researcher’s CV (or bottom line).

In the end, the “marketing crisis” in data science is coming from the same place as the “replication crisis” in statistics.  The idea that you can reduce statistics and data analysis (or analytics) down to some small set of rules that can be automatically applied is more than silly, it’s dangerous. So just as the stats community has begun the job of clawing back the opportunities we’ve lost to p=0.05, it’s time for data scientists to control their tail.

Untouchable face

The second article occurred, as Marya Dmitriyevna (who is old-school) in Natasha, Pierre, and the Great Comet of 1812 shrieks after Anatole (who is hot) tries to elope with Natasha (who is young) , in my house. So I’m going to spend most of this post on that. [It was pointed out to me that the first sentence is long and convoluted, even for my terrible writing. What can I say? It’s a complicated Russian novel, everyone’s got nine different names.]

(Side note: The only reason I go to New York is Broadway and cabaret. It has nothing to do with statistics and the unrepeatable set of people in one place. [please don’t tell Andrew. He thinks I like statistics.])

It turns out that deep neural networks join the illustrious ranks of “men driving past in cars”, “angry men in bars”, “men on the internet”,  and “that one woman at a numerical analysis conference in far north Queensland in 2006” in feeling obliged to tell me that I’m gay.

Now obviously I rolled my eyes so hard at this that I almost pulled a muscle.  I marvelled at the type of mind who would decide “is ‘gay face’ real” would be a good research question. I also really couldn’t understand why you’d bother training a neural network. That’s what instagram is for. (Again, amateurs, dilettantes, hacks, cowboys, clones.)

But of course, I’d only read the headline.  I didn’t really feel the urge to read more deeply.  I sent a rolled eyes emoji to the friend who thought I’d want to know about the article and went back about my life.

Once, twice, three times a lady

But last night, as the frat party next door tore through 2am (an unpleasant side-effect of faculty housing it seems) it popped up again on my facebook feed. This time it had grown an attachment ot that IBM story.  I was pretty tired and thought “Right. I can blog on this”.

(Because that’s what Andrew was surely hoping for, three thousand words on whether “gay face” is a thing. In my defence, I did say “are you sure?” more than once and reminded him what happened that one time X let me post on his blog.)

(Side note: unlike odd, rambling posts about a papers we’d just written, posts about bad statistics published in psychology journals is right in Andrew’s wheelhouse.  So why aren’t I waiting until mid 2018 for a post on this that he may or may not have written to appear? [DS 11Sept: Ha!] There’s not much that I can be confident that I know a lot more about than Andrew does, but I am very confident I know a lot more about “gay face”.)

So I read the Guardian article, which (wonder of wonders!) actually linked to the original paper. Attached to the original paper was an authors’ note, and an authors’ response to the inevitable press release from GLAAD calling them irresponsible.

Shall we say that there’s some drift from the paper to the press reports. I’d be interested to find out if there was at any point a press release marketing the research.

The main part that has gone AWOL is a rather long, dystopian discussion that the authors have about how they felt morally obliged to publish this research because people could do this with “off the shelf” tools to find gay people in countries where its illegal.  (We will unpack that later)

But the most interesting part is the tension between footnote 10 of the paper (“The results reported in this paper were shared, in advance, with several leading international LGBTQ organizations”) and the GLAAD/HRC press release that says

 Stanford University and the researchers hosted a call with GLAAD and HRC several months ago in which we raised these myriad concerns and warned against overinflating the results or the significance of them. There was no follow-up after the concerns were shared and none of these flaws have been addressed.

With one look

If you strip away all of the coverage, the paper itself does some tings right. It has a detailed discussion of the limitations of the data and the method. (More later)  It argues that, because facial features can’t be taught, these findings provide evidence towards the prenatal hormone theory of sexual orientation (ie that we’re “born this way”).

(Side note: I’ve never like the “born this way” narrative. I think it’s limiting.  Also, getting this way took quite a lot of work. Baby gays think they can love Patti and Bernadette at the same time. They have to learn that you need to love them with different parts of your brain or else they fight. My view is more “We’re recruiting. Apply within”.)

So do I think that this work should be summarily dismissed? Well, I have questions.

(Actually, I have some serious doubts, but I live in Canada now so I’m trying to be polite. Is it working?)

Behind the red door

Male facial image brightness correlates 0.19 with the probability of being gay, as estimated by the DNN-based classifier. While the brightness of the facial image might be driven by many factors, previous research found that testosterone stimulates melanocyte structure and function leading to a darker skin. (Footnote 6)

Again, it’s called instagram.

In the Authors’ notes attached to the paper, the authors recognise that “[gay men] take better pictures”, in the process acknowledging that they themselves have gay friends [honestly, there are too many links for that] who also possess this power. (Once more for those in the back: they’re called filters. Straight people could use them if they want. Let no photo go unmolested.)

(Side note: In 1989 Liza Minelli released a fabulous collaboration with the Petshop Boys that was apparently called Results because that’s what Janet Street-Porter used to call one of her outfits. I do not claim to understand straight men [nor am I looking to], but I have seen my female friends’ tinder. Gentlemen: you could stand to be a little more Liza.)

Back on top

But enough about methodology, let’s talk about data. Probably the biggest criticism that I can make of this paper is that they do not identify the source of their data. (Actually, in the interview with The Economist that originally announced the study, Kosinski says that this is intentional to “discourage copycats”.)

Obviously this is bad science.

(Side note: I cannot imagine the dating site in question would like its users to know that it allows its data to be scraped and analysed. This is what happens when you don’t read the “terms of service”, which I imagine the authors (and the ethics committee at Stanford) read very closely.)

[I’m just assuming that, as a study that used identifiable information about people who could not consent to being studied and deals with a sensitive study, this would’ve gone though an ethics process.]

This failure to disclose the origin of the data means we cannot contextualise it within the Balkanisation of gay desire. Gay men (at least, I will not speak for lesbians and I have nothing to say about bisexuals except “I thank you for your service”) will tell you what they want (what they really really want). This perverted and wonderful version of “The Secret” has manifested in multiple dating platforms that cater to narrow subgroups of the gay community.

Withholding information about the dating platform prevents people from independently scrutinising how representative the sample is likely to be. This is bad science.

(Side note: How was this not picked up by peer review? I’d guess it was reviewed by straight people. Socially active gay men should be able to pick a hole in the data in three seconds flat.  That’s the key point about diversity in STEM. It’s not about ticking boxes or meeting quotas. It’s that you don’t know what a minority can add to your work if they’re not in the room to add it.)

If you look at figure 4, the composite “straight” man is a trucker, while the composite “gay” man is a twunk. This strongly suggests that this is not my personal favourite type of gay dating site: the ones that caters to those of us who look like truckers. It also suggests that the training sample is not representative of the population the authors are generalising to. This is bad science.

(Terminology note: “Twunk” is the past form of “twink”, which is gay slang for a young (18-early20something), skinny, hairless gay man.)

The reality of gay dating websites is that you tailor your photographs to the target audience. My facebook profile picture (we will get to that later) is different to my grindr profile picture is different to my scruff profile picture. In the spirit of Liza, these are chosen for results. In these photos, I run a big part of the gauntlet between those two “composite ideals” in Figure 4. (Not all the way, because never having been a twink, and hence I never twunk.)

(Side note: The last interaction I had on Scruff was a two hour conversation about Patti LuPone. This is an “off-label” usage that is not FDA approved.)

So probably my biggest problem with this study is that it the training sample is likely unrepresentative of the population at large. This means that any inferences drawn from a model trained on this sample will be completely unable to answer questions about whether gay face is real in Caucasian Americans.  By withholding critical information about the data, the authors make it impossible to assess the extent of the problem.

One way to assess this error would be to take the classifier trained on their secret data and use it to, for example, classify face pics from a site like Scruff. There is a problem with this (as mentioned in the GLAAD/HRC press release) that activity and identity are not interchangeable. So some of the men who have sex with men (MSM, itself a somewhat controversial designation) will identify as neither gay nor bisexual and this is not necessarily information that would be available to the researcher. Nevertheless, it is probably safe to assume that people who have a publicly showing face picture on an dating app mainly used by MSMs are not straight.

If the classifier worked on this sort of data, then there is at least a chance that the findings of the study will replicate. But, those of you who read the paper of the Author notes howl, the authors did test the classifier on a validation sample gathered from Facebook.

At this point, let us pause to look at stills from Derek Jarman films. 

Pictures of you

First, we used the Facebook Audience Insights platform to identify 50 Facebook Pages most popular among gay men, including Pages such as: “I love being Gay”, “Manhunt”, “Gay and Fabulous”, and “Gay Times Magazine”. Second, we used the “interested in” field of users’ Facebook profiles, which reveals the gender of the people that a given user is interested in. Males that indicated an interest in other males, and that liked at least two out of the predominantly gay Facebook Pages, were labeled as gay.

I beseech you, in the Bowels of Christ, think it possible that that your validation sample may be biased.

(I mean, really. That’s one hell of an inclusion criterion.)

Rebel Girl / Nancy Boy

So what of the other GLAAD/HRC problems? They are mainly interesting to show the difference between the priorities of an advocacy organisation and statistical priorities. For example, the study only considered caucasians, which the press release criticises. The paper points out that there was not enough data to include people of colour. Without presuming to speak for LGB (the study didn’t consider trans people, so I’ve dropped the T+ letters [they also didn’t actively consider bisexuals, but LG sells washing machines]) people of colour, I can’t imagine that they’re disappointed to be left out of this specific narrative. That being said, the paper suggests that these results will generalise to other races. I am very skeptical of this claim.

Those composite faces also suggest that fat gay men don’t exist. Again, I am very happy to be excluded from this narrative.

What about the lesbians? Neural networks apparently struggle with lesbians. Again, it could be an issue of sampling bias. It could also be that the mechanical turk gender verification stage (4 of 6 people needed to agree with the person’s stated gender for them to be included) is adding additional bias.  The most reliable way to verify a person’s gender is to ask them.  I am uncertain why the researchers deviated from this principle. Certain sub-cultures in the LGB community identify as lesbian or gay but have either androgynous style, or purposely femme or butch style.  Systematically excluding these groups (I’m thinking particularly of butch lesbians and femme gays) will bias the results.

Breaking the law

So what of the dystopian picture the authors paint of governments using this type of procedure to find and eliminate homosexuals? Meh.

Just as I’m opposed to marketing in machine learning, I’m opposed to “story time” in otherwise serious research.  This claim makes the paper really exciting to read—you get to marvel at their moral dilemma. But the reality is much more boring. This is literally why universities (and I’m including Stanford in that category just to be nice) have ethics committees. I assume this study went through the internal ethics approval procedure, so the moralising is mostly pantomime.

The other reason I’m not enormously concerned about this is that I am skeptical of the idea that there is enough high-quality training data to train a neural network in countries where homosexuality is illegal (which are not white caucasian majority countries). Now I may well be very wrong about this, but I think we can all agree that it would be much harder than in the Caucasian case. LGBT+ people in these countries have serious problems, but neural networks are not one of them.

Researchers claiming that gay men, and to a slightly lesser extent lesbians, are structurally different from straight people is a problem. (I think we all know how phrenology was used to perpetuate racist myths.)  The authors acknowledge this during their tortured descriptions of their moral struggles over whether to publish the article. Given that, I would’ve expected the claims to be better validated. I just don’t believe that either their data set or their  validation set gives a valid representation of gay people.

All science should be good science, but controversial science should be unimpeachable. This study is not.

Live and let die (Gerri Halliwell version)

Ok. That’s more than enough of my twaddle. I guess the key point of this is that marketing and story telling, as well as being bad for science, gets in the way of effectively disseminating information.

Deep learning / neural networks / AI are all perfectly effective tools that can help people solve problems. But just like it wasn’t a generic convolutional neural network that wins games of Go, this tool only works when deployed by extremely skilled people. The idea that IBM could diagnose cancer with deep learning is just silly. IBM knows bugger all about cancer.

In real studies, selection of the data makes the difference between a useful step forward in knowledge and “junk science”.  I think there are more than enough problems with the “gay face” study (yes I will insist on calling it that) to be immensely skeptical. Further work may indicate that the authors’ preliminary results were correct, but I wouldn’t bet the farm on it. (I wouldn’t even bet a farm I did not own on it.) (In fact, if this study replicates I’ll buy someone a drink. [That someone will likely be me.])

The post It seemed to me that most destruction was being done by those who could not choose between the two appeared first on Statistical Modeling, Causal Inference, and Social Science.



Please comment on the article here: Statistical Modeling, Causal Inference, and Social Science

The post It seemed to me that most destruction was being done by those who could not choose between the two appeared first on All About Statistics.

]]>
/2017/09/12/it-seemed-to-me-that-most-destruction-was-being-done-by-those-who-could-not-choose-between-the-two/feed/ 0 /2017/09/12/it-seemed-to-me-that-most-destruction-was-being-done-by-those-who-could-not-choose-between-the-two/
“How conditioning on post-treatment variables can ruin your experiment and what to do about it” http://feedproxy.google.com/~r/statsblogs/~3/D-cb5ZKvYhg/ /2017/09/12/how-conditioning-on-post-treatment-variables-can-ruin-your-experiment-and-what-to-do-about-it/#comments Tue, 12 Sep 2017 13:57:58 +0000 Andrew http://andrewgelman.com/?p=35296

Brendan Nyhan writes: Thought this might be of interest – new paper with Jacob Montgomery and Michelle Torres, How conditioning on post-treatment variables can ruin your experiment and what to do about it. The post-treatment bias from dropout on Turk you just posted about is actually in my opinion a less severe problem than inadvertent […]

The post “How conditioning on post-treatment variables can ruin your experiment and what to do about it” appeared first on Statistical Modeling, Causal Inference, and Social Science.

The post “How conditioning on post-treatment variables can ruin your experiment and what to do about it” appeared first on All About Statistics.

]]>
(This article was originally published at Statistical Modeling, Causal Inference, and Social Science, and syndicated at StatsBlogs.)

Brendan Nyhan writes:

Thought this might be of interest – new paper with Jacob Montgomery and Michelle Torres, How conditioning on post-treatment variables can ruin your experiment and what to do about it.

The post-treatment bias from dropout on Turk you just posted about is actually in my opinion a less severe problem than inadvertent experimenter-induced bias due to conditioning on post-treatment variables in determining the sample (attention/manipulation checks, etc.) and controlling for them/using them as moderators. We show how common these practices are in top journal articles, demonstrate the problem analytically, and reanalyze some published studies. Here’s the table on the extent of the problem:

Post-treatment bias is not new but it’s an important area where practice hasn’t improved as rapidly as in other areas.

I wish they’d round their numbers to the nearest percentage point.

The post “How conditioning on post-treatment variables can ruin your experiment and what to do about it” appeared first on Statistical Modeling, Causal Inference, and Social Science.



Please comment on the article here: Statistical Modeling, Causal Inference, and Social Science

The post “How conditioning on post-treatment variables can ruin your experiment and what to do about it” appeared first on All About Statistics.

]]>
/2017/09/12/how-conditioning-on-post-treatment-variables-can-ruin-your-experiment-and-what-to-do-about-it/feed/ 0 /2017/09/12/how-conditioning-on-post-treatment-variables-can-ruin-your-experiment-and-what-to-do-about-it/
Surge protectors as teaching tools http://feedproxy.google.com/~r/statsblogs/~3/n1_FUcyzk6o/ /2017/09/12/surge-protectors-as-teaching-tools/#comments Tue, 12 Sep 2017 12:11:00 +0000 junkcharts /?guid=2f71c9f733fa00e21ad572d359b26071 Kaiser Fung, founder of Principal Analytics Prep, considers using surge protectors as an example for teaching probability and statistics.

The post Surge protectors as teaching tools appeared first on All About Statistics.

]]>
(This article was originally published at Big Data, Plainly Spoken (aka Numbers Rule Your World), and syndicated at StatsBlogs.)

My numbersense class for Principal Analytics Prep has passed the midway point, and we covered probabilistic thinking. Yesterday, the idea came to me that the surge protector is a good example to use in teaching probability. I just need to find some statistics - which turns out to be hard to come by... so if you know some sources, please let me know!

Appliances in the U.S. are rated 110 (or is it 120) volts. Anyone who have lived elsewhere (say, Europe or parts of Asia) may know that in some countries, appliances use 240 volts. If we take an American appliance to Europe, the 240 volts of electricity will immediately kill the device. The 110V or 240V standard is an average value, and we should expect fluctuations around those values (which are peaks of a sine curve). There is a natural variability in the voltage. 

Then there are surges. Statistically, we can define surges as rare events - maybe voltage that is at least three standard deviations above the normal value. (There may be an official definition but I wasn't able to find it on a quick Google search.) Surges are apparently caused by lightning or switching. (Here is a somewhat useful NIST document, which may have been partly or wholly written by suppliers of surge protection equipment.)

I would like to find some data on the statistical distribution of voltage delivered. Then, students can figure out if the data resemble a normal distribution or some other probability model. We can estimate the frequency of surges. This can lead to a quantitative assessment of expected loss due to power surges. 

Further, we must account for an asymmetrical cost structure. Having too low a voltage is also a problem. However, it is a much lesser problem compared to having a too high a voltage. There also does not appear to be such a thing as a "negative power surge". 

The above lays the groundwork for making a decision about whether one should buy a surge protector. There are different types of surge protectors providing different levels of protection at different prices. How can we decide whether to invest in the next better surge protector?

The NIST document referenced above makes this non-quantified assertion: "A large stack of dollar bills and some change to replace your unprotected computer, if and when a lightning or some other surge destroyed it ..... or use a small number of bills to purchase a 'surge protector' for peace of mind and effective protection." How can we quantify such a statement?

 



Please comment on the article here: Big Data, Plainly Spoken (aka Numbers Rule Your World)

The post Surge protectors as teaching tools appeared first on All About Statistics.

]]>
/2017/09/12/surge-protectors-as-teaching-tools/feed/ 0 /2017/09/12/surge-protectors-as-teaching-tools/
Quantifying the information content of personal data http://feedproxy.google.com/~r/statsblogs/~3/ABJNHBp-El4/ /2017/09/12/quantifying-the-information-content-of-personal-data/#comments Tue, 12 Sep 2017 11:55:47 +0000 John https://www.johndcook.com/blog/?p=28500 It can be surprisingly easy to identify someone from data that’s not directly identifiable. One commonly cited result is that the combination of birth date, zip code, and sex is enough to identify most people. This post will look at how to quantify the amount of information contained in such data. If the answer to […]

The post Quantifying the information content of personal data appeared first on All About Statistics.

]]>
(This article was originally published at Statistics – John D. Cook, and syndicated at StatsBlogs.)

It can be surprisingly easy to identify someone from data that’s not directly identifiable. One commonly cited result is that the combination of birth date, zip code, and sex is enough to identify most people. This post will look at how to quantify the amount of information contained in such data.

If the answer to a question has probability p, then it contains -log2 p bits of information. Knowing someone’s sex gives you 1 bit of information because -log2(1/2) = 1.

Knowing whether someone can roll their tongue could give you more or less information than knowing their sex. Estimates vary, but say 75% can roll their tongue. Then knowing that someone can roll their tongue gives you 0.415 bits of information, but knowing that they cannot roll their tongue gives you 2 bits of information.

On average, knowing someone’s tongue rolling ability gives you less information than knowing their sex. The average amount of information, or entropy, is

0.75(-log2 0.75) + 0.25(-log2 0.25) = 0.81.

Entropy is maximized when all outcomes equally likely. But for identifiability, we’re concerned with maximum information as well as average information.

Knowing someone’s zip code gives you a variable amount of information, less for densely populated zip codes and more for sparsely populated zip codes. An average zip code contains about 7,500 people. If we assume a US population of 326,000,000, this means a typical zip code would give us about 15.4 bits of information.

The Safe Harbor provisions of US HIPAA regulations let you use the first three digits of someone’s zip code except when this would represent less than 20,000 people, as it would in several sparsely populated areas. Knowing that an American lives in a region of 20,000 people would give you 14 bits of information about that person.

Birth dates are complicated because age distribution is uneven. Knowing that someone’s birth date was over a century ago is highly informative, much more so than knowing it was a couple decades ago. That’s why the Safe Harbor provisions do not allow including age, much less birth date, for people over 90.

Birthdays are simpler than birth dates. Birthdays are not perfectly evenly distributed throughout the year, but they’re close enough for our purposes. If we ignore leap years, a birthday contains -log2(1/365) or about 8.5 bits of information. If we consider leap years, knowing someone was born on a leap day gives us two extra bits of information.

Independent information is additive. I don’t expect there’s much correlation between sex, geographical region, and birthday, so you could add up the bits from each of these information sources. So if you know someone’s sex, their zip code (assuming 7,500 people), and their birthday (not a leap day), then you have 25 bits of information, which may be enough to identify them.

This post didn’t consider correlated information. For example, suppose you know someone’s zip code and primary language. Those two pieces of information together don’t provide as much information the sum of the information they provide separately because language and location are correlated. I may discuss the information content of correlated information in a future post.

Related: HIPAA de-identification



Please comment on the article here: Statistics – John D. Cook

The post Quantifying the information content of personal data appeared first on All About Statistics.

]]>
/2017/09/12/quantifying-the-information-content-of-personal-data/feed/ 0 /2017/09/12/quantifying-the-information-content-of-personal-data/
God, goons, and gays: 3 quick takes http://feedproxy.google.com/~r/statsblogs/~3/lI9TA5Vhu20/ /2017/09/11/god-goons-and-gays-3-quick-takes/#comments Mon, 11 Sep 2017 23:13:46 +0000 Andrew http://andrewgelman.com/?p=36633

Next open blog spots are in April but all these are topical so I thought I’d throw them down right now for ya. 1. Alex Durante writes: I noticed that this study on how Trump supporters respond to racial cues is getting some media play, notably over at Vox. I was wondering if you have […]

The post God, goons, and gays: 3 quick takes appeared first on Statistical Modeling, Causal Inference, and Social Science.

The post God, goons, and gays: 3 quick takes appeared first on All About Statistics.

]]>
(This article was originally published at Statistical Modeling, Causal Inference, and Social Science, and syndicated at StatsBlogs.)

Next open blog spots are in April but all these are topical so I thought I’d throw them down right now for ya.

1. Alex Durante writes:

I noticed that this study on how Trump supporters respond to racial cues is getting some media play, notably over at Vox. I was wondering if you have any thoughts on it. At first glance, it seems to me that its results are being way overhyped. Thanks for your time.

Here’s a table showing one of their analyses:

My reaction to this sort of thing is: (a) I won’t believe this particular claim until I see the preregistered replication. Too many forking paths. And (b) of course it’s true that “Supporters and Opponents of Donald Trump Respond Differently to Racial Cues” (that’s the title of the paper). How could that not be true, given that Trump and Clinton represent different political parties with way different positions on racial issues? So I don’t really know what’s gained by this sort of study that attempts to scientifically demonstrate a general claim that we already know, by making a very specific claim that I have no reason to think will replicate. Unfortunately, a lot of social science seems to work this way.

Just to clarify: I think the topic is important and I’m not opposed to this sort of experimental study. Indeed, it may well be that interesting things can be learned from the data from this experiment, and I hope the authors make their raw data available immediately. I’m just having trouble seeing what to do with these specific findings. Again, if the only point is that “Supporters and Opponents of Donald Trump Respond Differently to Racial Cues,” we didn’t need this sort of study in the first place. So the interest has to be in the details, and that’s where I’m having problems with the motivation and the analysis.

2. A couple people pointed me to this paper from 2006 by John “Mary Rosh” Lott, “Evidence of Voter Fraud and the Impact that Regulations to Reduce Fraud Have on Voter Participation Rates,” which is newsworthy because Lott has some connection to this voter commission that’s been in the news. Lott’s empirical analysis is essentially worthless because he’s trying to estimate causal effects from a small dataset by performing unregularized least squares with a zillion predictors. It’s the same problem as this notorious paper (not by Lott) on gun control that appeared in the Lancet last year. I think that if you were to take Lott’s dataset you could with little effort obtain just about any conclusion you wanted by just fiddling around with which variables go into the regression.

3. Andrew Jeon-Lee points us to this post by Philip Cohen regarding a recent paper by Yilun Wang and Michal Kosinski that uses a machine learning algorithm and reports, “Given a single facial image, a classifier could correctly distinguish between gay and heterosexual men in 81% of cases, and in 71% of cases for women. Human judges achieved much lower accuracy: 61% for men and 54% for women.”

Hey, whassup with that? I can get 97% accuracy by just guessing Straight for everybody.

Oh, it must depend on the population they’re studying! Let’s read the paper . . . they got data on 37000 men and 39000 women, approx 50/50 gay/straight. So I guess my classification rule won’t work.

More to the point, I’m guessing that the classification rule that will work will depend a lot on what population you’re using.

I had some deja vu on this one because last year there was a similar online discussion regarding a paper by Xiaolin Wu and Xi Zhang demonstrating an algorithmic classification of faces of people labeled as “criminals” and “noncriminals” (which I think makes even less sense than labeling everybody as straight or gay, but that’s another story). I could’ve sworn I blogged something on that paper but it didn’t show up in any search so I guess I didn’t bother (or maybe I did write something and it’s somewhere in the damn queue).

Anyway, I had the same problem with that paper from last year as I have with this recent effort: it’s fine as a classification exercise, and it can be interesting to see what happens to show up in the data (lesbians wear baseball caps!), but the interpretation is way over the top. It’s no surprise at all that two groups of people selected from different populations will differ from each other. That will be the case if you compare a group of people from a database of criminals to a group of people from a different database, or if you compare a group of people from a gay dating website to a group of people from a straight data website. And if you have samples from two different populations and a large number of cases, then you should be able to train an algorithm to distinguish them at some level of accuracy. Actually doing this is impressive (not necessarily an impressive job by these researchers, but it’s an impressive job by whoever wrote the algorithms that these people ran). It’s an interesting exercise, and the fact that the algorithms outperform unaided humans, that’s interesting too. But this kind of thing: like “The phenomenon is, clearly, troubling to those who hold privacy dear—especially if the technology is used by authoritarian regimes where even a suggestion of homosexuality or criminal intent may be viewed harshly.” That’s just silly, as it completely misses the point that the success of these algorithms entirely depends on the data used to train them.

Also Cohen in his post picks out this quote from the article in question:

[The results] provide strong support for the PHT [prenatal hormone theory], which argues that same-gender sexual orientation stems from the underexposure of male fetuses and overexposure of female fetuses to prenatal androgens responsible for the sexual differentiation of faces, preferences, and behavior.

Huh? That’s just nuts. I agree with Cohen that it would be better to say that the results are “not inconsistent” with the theory, just as they’re not inconsistent with other theories such as the idea that gay people are vampires (or, to be less heteronormative, the idea that straight people lack the vampirical gene).

Also some goofy stuff about the fact that gay men in this particular sample are less likely to have beards.

In all seriousness, I think the best next step here, for anyone who wants to continue research in this area, is to do a set of “placebo control” studies, as they say in econ, each time using the same computer program to classify people chosen from two different samples, for example college graduates and non-college graduates, or English people and French people, or driver’s license photos in state X and driver’s license photos in state Y, or students from college A and students from college B, or baseball players and football players, or people on straight dating site U and people on straight dating site V, or whatever. Do enough of these different groups and you might get some idea of what’s going on.

The post God, goons, and gays: 3 quick takes appeared first on Statistical Modeling, Causal Inference, and Social Science.



Please comment on the article here: Statistical Modeling, Causal Inference, and Social Science

The post God, goons, and gays: 3 quick takes appeared first on All About Statistics.

]]>
/2017/09/11/god-goons-and-gays-3-quick-takes/feed/ 0 /2017/09/11/god-goons-and-gays-3-quick-takes/
Christopher Salahub on Markov Chains – The Central Equilibrium – Episode 2 http://feedproxy.google.com/~r/statsblogs/~3/_8ya84mxU6A/ /2017/09/11/christopher-salahub-on-markov-chains-the-central-equilibrium-episode-2/#comments Mon, 11 Sep 2017 16:18:22 +0000 Eric Cai - The Chemical Statistician http://chemicalstatistician.wordpress.com/?p=3761 It was a great pleasure to talk to Christopher Salahub about Markov chains in the second episode of my new talk show, The Central Equilibrium!  Chris graduated from the University of Waterloo with a Bachelor of Mathematics degree in statistics.  He just finished an internship in data development at Environics Analytics, and he is starting […]

The post Christopher Salahub on Markov Chains – The Central Equilibrium – Episode 2 appeared first on All About Statistics.

]]>
(This article was originally published at Statistics – The Chemical Statistician, and syndicated at StatsBlogs.)

It was a great pleasure to talk to Christopher Salahub about Markov chains in the second episode of my new talk show, The Central Equilibrium!  Chris graduated from the University of Waterloo with a Bachelor of Mathematics degree in statistics.  He just finished an internship in data development at Environics Analytics, and he is starting a Master’s program in statistics at ETH Zurich in Switzerland.

Chris recommends “Introduction to Probability Models” by Sheldon Ross to learn more about probability theory and Markov chains.

The Central Equilibrium is my new talk show about math, science, and economics. It focuses on technical topics that involve explanations with formulas, equations, graphs, and diagrams.  Stay tuned for more episodes in the coming weeks!

You can watch all of my videos on my YouTube channel!

Please view this blog post beneath the fold to watch the video on this blog.  You can also watch it directly on YouTube.


Filed under: Applied Mathematics, Applied Statistics, Mathematical Statistics, Mathematics, Probability, Statistics, The Central Equilibrium, Video Tagged: chris salahub, christopher salahub, markov, markov chains, math, mathematics, probability, statistics, The Central Equilibrium



Please comment on the article here: Statistics – The Chemical Statistician

The post Christopher Salahub on Markov Chains – The Central Equilibrium – Episode 2 appeared first on All About Statistics.

]]>
/2017/09/11/christopher-salahub-on-markov-chains-the-central-equilibrium-episode-2/feed/ 0 /2017/09/11/christopher-salahub-on-markov-chains-the-central-equilibrium-episode-2/
The StanCon Cometh http://feedproxy.google.com/~r/statsblogs/~3/YMmj4Cexy_8/ /2017/09/11/the-stancon-cometh/#comments Mon, 11 Sep 2017 14:00:30 +0000 Mike Betancourt http://andrewgelman.com/?p=36611

(In a stunning deviation from the norm, this post is not by Andrew or Dan, but Betancourt!) Some important dates for StanCon2018 are rapidly approaching! Contributed submissions are due September 16, 2017 5:00:00 AM GMT. That’s less than 6 days away!  We want to make sure we can review submissions early enough to get responses back […]

The post The StanCon Cometh appeared first on Statistical Modeling, Causal Inference, and Social Science.

The post The StanCon Cometh appeared first on All About Statistics.

]]>
(This article was originally published at Statistical Modeling, Causal Inference, and Social Science, and syndicated at StatsBlogs.)

(In a stunning deviation from the norm, this post is not by Andrew or Dan, but Betancourt!)

Some important dates for StanCon2018 are rapidly approaching!

Contributed submissions are due September 16, 2017 5:00:00 AM GMT. That’s less than 6 days away!  We want to make sure we can review submissions early enough to get responses back to submitters in time for early registration.  For more details on the submission requirements and how to submit see the Submissions page.

Speaking of which, early registration ends Friday November 10, 2017 after which the registration cost significantly increases. That’s in just about two months!

Finally, just because I still can’t believe that we have such an amazing ensemble of invited speakers let me remind everyone that attendees will get to see talks from

  • Susan Holmes (Department of Statistics, Stanford University)
  • Frank Harrell (School of Medicine and Department of Biostatistics, Vanderbilt University)
  • Sophia Rabe-Hesketh (Educational Statistics and Biostatistics, University of California, Berkeley)
  • Sean Taylor and Ben Letham (Facebook Core Data Science)
  • Manuel Rivas (Department of Biomedical Data Science, Stanford University)
  • Talia Weiss (Department of Physics, Massachusetts Institute of Technology)

The post The StanCon Cometh appeared first on Statistical Modeling, Causal Inference, and Social Science.



Please comment on the article here: Statistical Modeling, Causal Inference, and Social Science

The post The StanCon Cometh appeared first on All About Statistics.

]]>
/2017/09/11/the-stancon-cometh/feed/ 0 /2017/09/11/the-stancon-cometh/
Looking for the bottom line http://feedproxy.google.com/~r/statsblogs/~3/pcSI_AUolE8/ /2017/09/11/looking-for-the-bottom-line/#comments Mon, 11 Sep 2017 13:16:26 +0000 Andrew http://andrewgelman.com/?p=35294 I recommend this discussion of how to summarize posterior distributions. I don’t recommend summarizing by the posterior probability that the new treatment is better than the old treatment, as that is not a bottom-line statement! The post Looking...

The post Looking for the bottom line appeared first on All About Statistics.

]]>
(This article was originally published at Statistical Modeling, Causal Inference, and Social Science, and syndicated at StatsBlogs.)

I recommend this discussion of how to summarize posterior distributions. I don’t recommend summarizing by the posterior probability that the new treatment is better than the old treatment, as that is not a bottom-line statement!

The post Looking for the bottom line appeared first on Statistical Modeling, Causal Inference, and Social Science.



Please comment on the article here: Statistical Modeling, Causal Inference, and Social Science

The post Looking for the bottom line appeared first on All About Statistics.

]]>
/2017/09/11/looking-for-the-bottom-line/feed/ 0 /2017/09/11/looking-for-the-bottom-line/
2017 NBER-NSF Time Series Meeting http://feedproxy.google.com/~r/statsblogs/~3/L1DEpzI1ZPM/ /2017/09/11/2017-nber-nsf-time-series-meeting/#comments Mon, 11 Sep 2017 11:59:00 +0000 Francis Diebold /?guid=79e11b18f557ff2b866503a7b1e68a9e Just back from 2017 NBER-NSF Time Series at Northwestern.  Quite a feast -- my head is spinning.  Program dumped below; formatted version here.  Many thanks to the program committee for producing this event, and more generally for keepin...

The post 2017 NBER-NSF Time Series Meeting appeared first on All About Statistics.

]]>
(This article was originally published at No Hesitations, and syndicated at StatsBlogs.)

Just back from 2017 NBER-NSF Time Series at Northwestern.  Quite a feast -- my head is spinning.  Program dumped below; formatted version here.  Many thanks to the program committee for producing this event, and more generally for keeping the series going, year after year, stronger than ever.  (See here for some history and links to past locations, programs, etc.)

The papers were very strong.  Among those that I found particularly interesting are:

-- Moon.  Forecasting in short panels.  You'd think it would be impossible since you need the individual effects.  But it's not.

“Forecasting with Dynamic Panel Data Models”, Hyungsik Roger Moon (University of Southern California), Laura Liu, and Frank Schorfheide

-- Shephard.  Causal estimation meets time series.

“Time series experiments, causal estimands and exact p-values”, Neil Shephard (Harvard University) and Iavor Bojinov

-- The entire (and marvelously-coherent) "Lumsdaine Sesssion" (Pruitt, Pelger, Giglio).  Real progress on econometric methods for identifying financial-market risk factors, with sharp empirical results. 

“Instrumented Principal Component Analysis”, Seth Pruitt (Arizona State University), Bryan Kelly, and Yinan Su
“Estimating Latent Asset-Pricing Factors”, Markus Pelger (Stanford University) and Martin Lettau

“Inference on Risk Premia in the Presence of Omitted Factors”, Stefano Giglio (University of Chicago) and Dacheng Xiu



------------------

2017 NBER-NSF Time Series Conference
Friday, September 8 – Saturday, September 9
Kellogg School of Management
Kellogg Global Hub
2211 N Campus Drive; Evanston, IL 60208
Friday, September 8
Registration begins 10:20am (White Auditorium)
Welcome and opening remarks: 10:50am
Session 1: 11:00am – 12:30pm
Chair: Ruey S. Tsay (University of Chicago)
 “Egalitarian Lasso for Shrinkage and Selection in Forecast Combination” Francis X. Diebold (University of Pennsylvania) and Minchul Shin
 “Forecasting with Dynamic Panel Data Models” Hyungsik Roger Moon (University of Southern California), Laura Liu, and Frank Schorfheide
 “Large Vector Autoregressions with Stochastic Volatility and Flexible Priors” Andrea Carriero (Queen Mary University of London), Todd E. Clark, and Massimiliano Marcellino
12:30pm - 2:00pm: Lunch and Poster Session 1 (Faculty Summit, 4th Floor)
 “The Dynamics of Expected Returns: Evidence from Multi-Scale Time Series Modeling“ Daniele Bianchi (University of Warwick)
 “Testing for Unit-root Non-stationarity against Threshold Stationarity” Kung-Sik Chan (University of Iowa)
 “Group Orthogonal Greedy Algorithm for Change-point Estimation of Multivariate Time Series” Ngai Hang Chan (The Chinese University of Hong Kong)
 “The Impact of Waiting Times on Volatility Filtering and Dynamic Portfolio Allocation” Dobrislav Dobrev (Federal Reserve Board of Governors)
 “Testing for Mutually Exciting Jumps and Financial Flights in High Frequency Data” Mardi Dungey (University of Tasmania), Xiye Yang (Rutgers University) presenting
 “Pockets of Predictability” Leland E. Farmer (University of California, San Diego)
 “Factor Models of Arbitrary Strength” Simon Freyaldenhoven (Brown University)
 “Inference for VARs Identified with Sign Restrictions” Eleonora Granziera (Bank of Finland)
 “The Time-Varying Effects of Conventional and Unconventional Monetary Policy: Results from a New Identification Procedure” Atsushi Inoue (Vanderbilt University)
 “On spectral density estimation via nonlinear wavelet methods for non-Gaussian linear processes” Linyuan Li (University of New Hampshire)
 “Multivariate Bayesian Predictive Synthesis in Macroeconomic Forecasting” Kenichiro McAlinn (Duke University)
 “Periodic dynamic factor models: Estimation approaches and applications” Vladas Pipiras (University of North Carolina)
 “Canonical stochastic cycles and band-pass filters for multivariate time series” Thomas M. Trimbur (U. S. Census Bureau)
Session 2: 2:00pm - 3:30pm
Chair: Giorgio Primiceri (Northwestern University)
 “Understanding the Sources of Macroeconomic Uncertainty” Tatevik Sekhposyan (Texas A&M University), Barbara Rossi, and Matthieu Soupre
 “Safety, Liquidity, and the Natural Rate of Interest” Marco Del Negro (Federal Reserve Bank of New York), Domenico Giannone, Marc P. Giannoni, and Andrea Tambalotti
 “Structural Interpretation of Vector Autoregressions with Incomplete Identification: Revisiting the Role of Oil Supply and Demand Shocks” Christiane Baumeister (University of Notre Dame) and James D. Hamilton
Afternoon Break: 3:30pm-4:00pm
Session 3: 4:00pm – 5:30pm
Chair: Serena Ng (Columbia University)
 “Controlling the Size of Autocorrelation Robust Tests” Benedikt M. Pötscher (University of Vienna) and David Preinerstorfer
 “Heteroskedasticity Autocorrelation Robust Inference in Time Series” Regressions with Missing Data Timothy J. Vogelsang (Michigan State University) and Seung-Hwa Rho
 “Time series experiments, causal estimands and exact p-values” Neil Shephard (Harvard University) and Iavor Bojinov
5:30pm – 7pm: Cocktail Reception and Poster Session 2 (Faculty Summit, 4th Floor)
 “Macro Risks and the Term Structure of Interest Rates” Andrey Ermolov (Fordham University)
 “Holdings-based Fund Performance Measures: Estimation and Inference” Wayne E. Ferson (University of Southern California), Junbo L. Wang (Louisiana State University) presenting
 “Economic Predictions with Big Data: The Illusion of Sparsity” Domenico Giannone (Federal Reserve Bank of New York)
 “Estimation and Inference of Dynamic Structural Factor Models with Over-identifying Restrictions” Xu Han (City University of Hong Kong)
 “Bayesian Predictive Synthesis: Forecast Calibration and Combination” Matthew C. Johnson (Duke University)
 “Time Series Modeling on Dynamic Networks” Jonas Krampe (TU Braunschweig)
 “The Complexity of Bank Holding Companies: A Topological Approach” Robin L. Lumsdaine (American University)
 “Sieve Estimation of Option Implied State Price Density” Zhongjun Qu (Boston University) - Junwen Lu (Boston University) presenting
 “Linear Factor Models and the Estimation of Expected Returns” Cisil Sarisoy (Northwestern University)
 “Efficient Parameter Estimation for Multivariate Jump-Diffusions” Gustavo Schwenkler (Boston University)
 “News-Driven Uncertainty Fluctuations” Dongho Song (Boston College)
 “Contagion, Systemic Risk and Diagnostic Tests in Large Mixed Panels” Cindy S.H. Wang (National Tsing Hua University and CORE, University Catholique de Louvain)
7-10pm: Dinner (White Auditorium)
 Dinner speaker: Nobel Laureate Robert F. Engle
Saturday, September 9
Continental Breakfast: 8:00am – 8:30am
Registration begins 8:30am (White Auditorium)
Session 4: 9:00am – 10:30am
Chair: Thomas Severini (Northwestern University)
 “Estimation of time varying covariance matrices for large datasets” Liudas Giraitis (Queen Mary University of London), Y. Dendramis, and G. Kapetanios
 “Indirect Inference With(Out) Constraints” Eric Renault (Brown University) and David T. Frazier
 “Edgeworth expansions for a class of spectral density estimators and their applications to interval estimation” S.N. Lahiri (North Carolina State University) and A. Chatterjee
Morning Break: 10:30am-11:00am
Session 5: 11:00am-12:30pm
Chair: Robin L. Lumsdaine (American University)
 “Instrumented Principal Component Analysis” Seth Pruitt (Arizona State University), Bryan Kelly, and Yinan Su
 “Estimating Latent Asset-Pricing Factors” Markus Pelger (Stanford University) and Martin Lettau
 “Inference on Risk Premia in the Presence of Omitted Factors” Stefano Giglio (University of Chicago) and Dacheng Xiu
12:30pm-2pm: Lunch and Poster Session 3 (Faculty Summit, 4th Floor)
 “Regularizing Bayesian Predictive Regressions” Guanhao Feng (City University of Hong Kong)
 “Good Jumps, Bad Jumps, and Conditional Equity Premium” Hui Guo (University of Cincinnati)
 “High-dimensional Linear Regression for Dependent Observations with Application to Nowcasting” Yuefeng Han (The University of Chicago)
 “Maximum Likelihood Estimation for Integer-valued Asymmetric GARCH (INAGARCH) Models” Xiaofei Hu (BMO Harris Bank, N.A.)
 “Tail Risk in Momentum Strategy Returns” Soohun Kim (Georgia Institute of Technology)
 “The Perils of Counterfactual Analysis with Integrated Processes” Marcelo C. Medeiros (Pontifical Catholic University of Rio de Janeiro) and Ricardo Masini (Pontifical Catholic University of Rio de Janeiro)
 “Anxious unit root processes” Jon Michel (The Ohio State University)
 “Limiting Local Powers and Power Envelopes of Panel AR and MA Unit Root Tests” Katsuto Tanaka (Gakushuin University)
 “High-Frequency Cross-Market Trading: Model Free Measurement and Applications”
Ernst Schaumburg (AQR Capital Management, LLC) – Dobrislav Dobrev (Federal Reserve Board of Governors) presenting
 “A persistence-based Wold-type decomposition for stationary time series” Claudio Tebaldi (Bocconi University)
 “Necessary and Sufficient Conditions for Solving Multivariate Linear Rational Expectations Models and Factoring Matrix Polynomials” Peter A. Zadrozny (Bureau of Labor Statistics)
Session 6: 2:00pm – 3:30pm
Chair: Beth Andrews (Northwestern University)
 “Models for Time Series of Counts with Shape Constraints” Richard A. Davis (Columbia University) and Jing Zhang
 “Computationally Efficient Distribution Theory for Bayesian Inference of High-Dimensional Dependent Count-Valued Data” Scott H. Holan (University of Missouri, U.S. Census Bureau), Jonathan R. Bradley, and Christopher K. Wikle
 “Functional Autoregression for Sparsely Sampled Data”
Daniel R. Kowal (Cornell University, Rice University)



Please comment on the article here: No Hesitations

The post 2017 NBER-NSF Time Series Meeting appeared first on All About Statistics.

]]>
/2017/09/11/2017-nber-nsf-time-series-meeting/feed/ 0 /2017/09/11/2017-nber-nsf-time-series-meeting/
Symbolic derivatives in SAS http://feedproxy.google.com/~r/statsblogs/~3/4JAXsb5vC4E/ /2017/09/11/symbolic-derivatives-in-sas/#comments Mon, 11 Sep 2017 09:28:10 +0000 Rick Wicklin http://blogs.sas.com/content/iml/?p=20133

Did you know that you can get SAS to compute symbolic (analytical) derivatives of simple functions, including applying the product rule, quotient rule, and chain rule? SAS can form the symbolic derivatives of single-variable functions and partial derivatives of multivariable functions. Furthermore, the derivatives are output in a form that [...]

The post Symbolic derivatives in SAS appeared first on The DO Loop.

The post Symbolic derivatives in SAS appeared first on All About Statistics.

]]>
(This article was originally published at The DO Loop, and syndicated at StatsBlogs.)

Did you know that you can get SAS to compute symbolic (analytical) derivatives of simple functions, including applying the product rule, quotient rule, and chain rule? SAS can form the symbolic derivatives of single-variable functions and partial derivatives of multivariable functions. Furthermore, the derivatives are output in a form that can be pasted into a SAS program. The trick is to use PROC NLIN with the LIST option.

In SAS/IML, the nonlinear optimization routines will use analytical derivatives if they are provided; otherwise, they will automatically generate numerical finite-difference approximations to the derivatives. I rarely specify derivatives because it can be time-consuming and prone to error. But recently I realized that PROC NLIN and other SAS procedures automatically generate symbolic derivatives, and you can "trick" the procedure into displaying the derivatives so that they can be used in other applications. To get PROC NLIN to output symbolic derivatives, do the following:

  • Create a data set to use for the DATA= option of PROC NLIN.
  • List the variables that you want to take derivatives of on the PARMS statement. In open code, assign a value to constants that appear in the function.
  • Specify the function to differentiate on the MODEL statement.

Symbolic derivatives of functions of one variable

Here is a one-variable example. Suppose you want to take the derivative of
f(x) = x3 + x sin(x) + exp( x2 ).
The function and its derivative is shown to the right.

The following SAS statements create a "fake" data set that defines a variable named F. The call to PROC NLIN sets up the problem. The LIST option on the PROC NLIN statement generates the 'ProgList' table, which contains the derivative function:

data _dummy;
   f = 1;                                    /* name of function */
run;
 
proc nlin data=_dummy list;
   parms x=0;                                /* list variables */
   model f = x**3 + x*sin(x) + exp(x**2);    /* define function */
   ods select ProgList;                      /* output symbolic derivatives */
run;
Symbolic derivatibves in SAS for a univariate function

The output shows the expressions for the function ("MODEL.f") and the derivative with respect to x. The derivative df/dx is written as "@MODEL.f/@x", where the symbol '@' is used for the 'd'. You can see that SAS took the simple derivative of the x3 term, applied the product rule to the x*sin(x) term, and applied the chain rule to the exp( x2 ) term. You can also see that the expressions are written in SAS notation, with "**" indicating the power operator. SAS functions are written in upper case (SIN, COS, and EXP).

Symbolic partial derivatives of multivariate functions

In exactly the same way, you can obtain partial derivatives. In a partial derivative, all variables are held constant except one. Suppose you have the function for the normal density,
f(x) = 1/(sqrt(2 π) σ) exp( -(x - μ)**2 / (2 σ**2) )
Suppose that you want to compute the partial derivatives ∂f/∂μ and ∂f/∂σ. To compute these derivatives, list μ and σ on the PARMS statement and assign values to the other symbols (x and π) that appear in the function. It does not matter what value you assign to the x and π, you are just preventing PROC NLIN from complaining that there are unassigned variables. You could assign the value 1 to both variables, but I prefer to tell the procedure that π equals 3.14. In the following program, note that PROC NLIN reuses the fake data set that defines the F variable:

proc nlin data=_dummy list;
   parms mu=0 sigma=1;                        /* list variables */
   x=1; pi = constant('pi');                  /* assign arbitrary values to constants */
   model f = exp( -(x-mu)**2 / (2*sigma**2) ) / (sqrt(2*pi)*sigma); /* define function */
   ods select ProgList;                      /* output symbolic derivatives */
run;
Symbolic partial derivatibves in SAS for a multivariate function

The derivative with respect to σ requires using the chain rule and the quotient rule. Notice that the derivative includes a call to the original function ("MODEL.f"). Notice also that there is repetition of various expressions such as -(x - μ)**2 / (2 σ**2). If you copy and paste these expressions into a SAS program that computes the derivative, the computation will be slightly inefficient because the program will evaluate the same expression multiple times. One way to improve the efficiency is to collect sub-expressions into a temporary variable, as shown in the next section.

Sub-expressions and the chain rule

An experienced statistician will recognize that the expression z = (x - μ) / σ arises naturally as the standardized variable. Using such an expression might simplify the derivatives.

The following program computes the same derivatives as before, except this time the programmer defines the expression z = (x - μ) / σ and uses z in the function. When SAS takes the derivative, it computes dz/dμ and dz/dσ as part of the computation, as shown below:

proc nlin data=_dummy list;
   parms mu=0 sigma=1;                        /* list variables */
   x=1; pi = constant('pi');                  /* assign arbitrary values to constants */
   const = sqrt(2*pi);
   z = (x-mu) / sigma;                        /* intermediate expression */
   model f = exp(-z**2 / 2) / (const*sigma);  /* define function */
   ods select ProgList;                       /* output symbolic derivatives */
run;
Symbolic derivatibves in SAS that use sub-expressions and apply the chain rule

Notice that the derivatives use several sub-expressions such as dz/dμ and dz/dσ. This computation is more efficient than the previous because it reuses previously computed quantities. For another example, define f1 = 1 / sqrt(2*pi*sigma) and f2 = exp(-z**2 / 2) and define the MODEL as f = f1*f2. You will see that each term in the derivative is efficiently evaluated in terms of previously expressions.

Discussion of symbolic derivatives

As I said previously, I do not usually specify analytical derivatives for my optimizations. I find that numerical derivatives (which are automatically computed) are fast and accurate for 99% of the optimizations that I perform.

Furthermore, some of the objective functions that I optimize do not have analytical derivatives. Others are matrix computations for which it would be difficult and time-consuming to write down the analytical derivative. (For an example, see the article on the derivative of the bivariate normal cumulative distribution.)

If you decide to specify an analytical derivative in SAS, make sure that the derivative is correct and efficient. The technique in this article will help to ensure that the derivative is correct. By strategically defining sub-expressions as in the previous section, you can help SAS generate derivatives that are computationally efficient.

Be aware that the derivatives are generated by applying the chain rule, product rule, and quotient rule without any algebraic simplifications of the result. Thus the result can be unnecessarily complicated. For an example, ask SAS to display the derivative of log( (1+x)/(1-x) ) / 2. The naive result is complicated. If you rewrite the function as log(1+x)/2 - log(1-x)/2, then the derivative is much simpler. However, in neither case will SAS simplify the derivative to obtain 1 / (1-x**2).

For more of my thoughts on using derivatives in SAS, see "Two hints for specifying derivatives." What about your thoughts? What do you think about using PROC NLIN to generate automatic derivatives of simple functions? Do you think this technique will be useful to you?

The post Symbolic derivatives in SAS appeared first on The DO Loop.



Please comment on the article here: The DO Loop

The post Symbolic derivatives in SAS appeared first on All About Statistics.

]]>
/2017/09/11/symbolic-derivatives-in-sas/feed/ 0 /2017/09/11/symbolic-derivatives-in-sas/